XSS Vectors
- Split into multiple notes
# XSS Vectors
# XSS Vector Without Spaces, Using Throw
This payload is taken from the portswigger academy
lab. The request url is the following /post?postId=5&%27},x=x=%3E{onerror=alert;throw/**/1337},toString=x,window+'',{x:'<
. When the request is sent, the injected html looks like this:
|
|
When we extract just the href attribute, remove the javascript prefix and url-decode everything(remember, since we are in an href, url encoded values are actually used in their decoded form, so even though the ' is encoded to %27, it still closes the previous single quote) we are left with the js code:
|
|
What this vector does can be split up into steps:
- close the
body:
of the dictionary and close the dictionary, and add a new parameter to the call of thefetch()
function. - In this new call, define a new function
x
that always throws the error1337
a. When the function is called,window.onerror
is set to thealert
function, so every error thrown inx()
is passed toalert
b. then, we throw an error with the message1337
c.x(x)
also has a parameter named x, this is because we use the x function as a substitute fortoString
. If we hadn't defined it like that, the javascript interpreter would throw an error before we could even callx
, therefore, our payload wouldn't run. - Then, with
toString=x
, we set the toString function to x - Finally, we run
window+''
, which implicitly calls toString and therefore runs our malicious function x. - The rest are used to close the dictionary that we have injected into so that we end up with valid javascript.
# DOM Based XSS message
|
|