Context-Specific Bypass Techniques
Context-Specific Bypass Techniques
Different injection contexts require different bypass techniques, and sophisticated attackers tailor their payloads to the specific context. JavaScript string context bypasses might use template literals, escape sequences, or Unicode to break out of strings. CSS context bypasses exploit browser-specific CSS parsing quirks or legacy features. Understanding these context-specific techniques helps developers implement appropriate defenses for each situation.
In JavaScript contexts, attackers use various techniques to bypass filters that might block quotes or escape sequences. Template literals (backticks) provide an alternative to quotes that filters might miss. JavaScript's flexible syntax allows comments, line continuations, and various operators to construct payloads that evade simple pattern matching. For example, ${alert(1)}
uses template literal syntax, while alert//comment\n(1)
uses comments and newlines to break up recognizable patterns.
Attribute context bypasses exploit the various ways browsers parse attributes. Unquoted attributes are particularly vulnerable, as many characters can terminate them. Even quoted attributes can be vulnerable if filters don't account for all quote characters browsers recognize. Some browsers interpret grave accents or other characters as quote equivalents in certain contexts. Event handlers provide rich bypass opportunities, as JavaScript can be embedded in numerous events beyond the obvious onclick.