XSS Reflected , Stored & Dom writeup
A beginner's write-up of reflected, stored and DOM cross-site scripting in a deliberately vulnerable practice application, showing that script tags and image error handlers execute in the page. An attacker could run their own JavaScript in a victim's browser and read the victim's cookies.
medium.com
Published on medium.com
The original lives on medium.com
We do not hold its text, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the application reflects and stores user input into the page without encoding it, and its filters only block a few exact strings rather than sanitising properly.
Impact
Script supplied by an attacker could run in a victim's browser and read their cookies, though the text only demonstrates this against a local practice application.
What the attacker needed
Access to the practice application; victim views the crafted input
The fix
The application should encode all user input on output and use an allow-list sanitiser instead of blocking individual strings.
How it was found
- Enter a script tag in the reflected XSS input and observe the alert pop-up.
- On the medium level, change the case of the tag or nest it to get past the filter.
- Replace the alert with a redirect that sends the cookie to a local listener.
- For stored XSS, submit an image tag with an error handler in the name field.
- On the high stored level, lengthen the name field before submitting the payload.
- For DOM XSS, close the option and select tags and inject an image error handler, or place the payload after the hash on the high level.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
Cross-site scripting (XSS) means a website puts text from a user back into the page without cleaning it, so the browser treats that text as code. Here the author typed small snippets into a search box and a name field, and the page ran them as JavaScript, which let the snippet read the visitor's cookies (small pieces of saved login data).
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.