Stored XSS with HTTP only Session Cookies
A stored cross-site scripting (XSS) vulnerability was found in a JSON object inside script tags, allowing an attacker to execute JavaScript. Although the session cookie was HTTP-only, the attacker could bypass this by loading the profile page in an iframe and reading the cookie value from the DOM, demonstrating that sensitive cookies can be accessed via JavaScript.
medium.com
Published on medium.com
View full article: https://hogarth45.com/stored-xss-with-http-only-session-cookies/
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 embedded the session cookie value inside a JSON object in the page's HTML, making it accessible to JavaScript despite the HTTP-only flag.
What the attacker needed
Victim visits a page with the stored XSS; attacker can inject script into a JSON object
How it was found
- Find an XSS location inside a JSON object within script tags.
- Break out of the script context using a closing script tag.
- Inject an iframe that loads the profile page.
- Add a script that waits for the iframe to load and reads the cookie data from the DOM.
- Extract the session cookie value from the JSON and display it.
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) lets an attacker run their own JavaScript in a victim's browser on a trusted site. Normally, a security flag called HTTP-only stops JavaScript from reading cookies, but here the cookie value was also written into the page's HTML, so the attacker could read it from there instead.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.