XSS filter evasion through invalid escapes
Most of the time, XSS filters look for specific keywords to detect invocation of dangerous functions or variables. A very common bypass technique is to break these specific character sequences like this:
window.alert() can also be written using square-bracket notation: window['alert']()
This is good because now the alert method/property is a string which means that it can be obfuscated using all kinds of string functions:
window['ale'+'rt'](1)
window['alexrt'.replace(/x/,'')](1)
Several years ago I found a nice feature in javascript that allows the attacker to break character sequences in a very easy, quick and shorter way. It consists of escaping characters that do not have an escape sequence assigned. For instance, this are valid escapes in javascript:
\' Simple quote
\" Double doble
\ Backslash
\n New line
\r Carriage return
\v Vertical tab
\t Tab
\b Backspace
\f Page forward
Those characters will be escaped to their corresponding values if you add a backslash before them.
If you use a backslash before any other character javascript will simply ignore the backslashes, so the string will be broken while still preserving its meaning:
window['\a\l\ert'](1)
window['\pr\o\m\pt'](1)
I hope this will help to do your hacking simpler and faster.
Filed under: Hacking,Web Application Security,XSS - @ 2023-07-28 18:11