The Illusion of Safety: Exploiting XSS Beyond "HttpOnly" Cookies
A stored XSS vulnerability via SVG uploads allowed JavaScript execution in the admin's browser, but the session cookie was HttpOnly so it couldn't be stolen. The attacker chained the XSS to read the CSRF token from local storage and automatically send a request to promote a user to admin, bypassing CSRF protection.
medium.com
Published on medium.com
Hello Hackers! Hope you are doing great.
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
Root cause
Likely the application failed to sanitise SVG file uploads, allowing JavaScript execution, and stored the CSRF token in local storage where it could be read by the injected script.
What the attacker needed
Attacker can upload an SVG file; admin views the uploaded image; CSRF token stored in local storage
The fix
The application should sanitise SVG uploads to prevent JavaScript execution and avoid storing CSRF tokens in local storage, or use a more secure mechanism.
How it was found
- A normal user uploads an SVG file containing malicious JavaScript as their profile picture.
- The admin clicks 'View Image' to load the user's profile picture.
- The JavaScript executes and reads the CSRF token from local storage.
- The script sends a POST request to /promote-user with the stolen CSRF token, promoting the user to admin.
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.
The website let users upload SVG image files without properly checking their content, so an attacker could hide JavaScript inside an image. When an admin viewed that image, the script ran in the admin's browser. Although the login cookie was protected from being read by scripts, the script could still read a security token stored in the browser and use it to send a request that made the attacker an admin.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.