How I Discovered a Stored XSS Vulnerability in JS Files
A user input field lacked proper sanitisation, allowing stored cross-site scripting. An attacker could inject a script that executes whenever the page is viewed, potentially hijacking sessions or stealing cookies.
cybersecuritywriteups.com
Published on cybersecuritywriteups.com
Ever wondered how a casual dive into JavaScript files could uncover a lurking security nightmare? I certainly didn’t — until I did!
The full write-up lives on its author's site
It belongs to its author, 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
Impact
An attacker could hijack sessions, steal cookies, or deface the website with persistent malicious code.
What the attacker needed
A user input field that stores data; victim views the page displaying the stored input
The fix
The application should rigorously validate and sanitise all user input on both client and server sides, and properly encode output before rendering it.
How it was found
- Find a user input field, such as a comment field, that lacks proper sanitisation.
- Inject a script payload into that field.
- Load the page where the stored input is displayed.
- Observe that the script executes automatically for every viewer.
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.
Stored cross-site scripting (XSS) happens when a website saves harmful code entered by a user and later shows it to other visitors without cleaning it first. The code then runs in the visitor's browser, which can let an attacker take over their session or read their cookies.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.