How I Turned Stored XSS Into Account Takeover: Exploiting WebSock
A stored cross-site scripting flaw in a template preview feature let an attacker run script in other users' sessions, and the application's WebSocket login accepted any user's login token, so a stolen token gave full access to that account. The author chained both to take over accounts, including changing the victim's email address.
Published on medium.com
In a Recent Security Engagement with BugSwagger, LLC. The Scope was only a Singe Subdomain demo.xzy.com the Application was built with a popular JavaScript framework.
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 server trusted a client-supplied login token without binding it to the original session, and the template preview rendered stored input without encoding.
Impact
An attacker could steal any user's login token and take over their account, including changing the victim's email address, and could reach every user who opened the published template.
What the attacker needed
A normal user account; victim opens the template in preview; attacker can host an external listener
How it was found
- Log in as a normal user and watch the WebSocket traffic in an intercepting proxy.
- Notice the login message carries a login token, then log in as a second user and resend the first user's message with the second user's token.
- Observe that the server returns the second user's account details.
- Create a template and inject a script payload outside the paragraph tag, bypassing the client-side encoding.
- Open the template in preview mode and confirm the script runs, including in another user's session.
- Replace the payload with one that sends the browser's local storage to an external listener, then preview again to capture the token.
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 site let people save a template containing hidden code that runs in the browser of anyone who views it. Separately, the site's live connection accepted a session token without checking it belonged to the person using it, so stealing a token was enough to become that user.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.