How I Uncovered a Sneaky DOM XSS Bug in a Popular Social Media Platform — And Scored a $4,000 Bug…
A social media platform displayed user-supplied URLs in comments without proper HTML escaping, allowing an attacker to inject an image tag with an event handler that executed JavaScript. The attacker could steal session cookies and potentially hijack accounts of users who viewed the infected comment.
Published on theindiannetwork.medium.com
It’s one thing to hunt for vulnerabilities in e-commerce sites or corporate websites. But what happens when you find a vulnerability in social media platforms — websites where millions of users interact daily?
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 platform inserted user-supplied comment content into the DOM without escaping HTML or sanitising it, allowing event-handler attributes to execute.
Impact
An attacker could steal session cookies from any user who viewed the infected comment, potentially leading to full account hijacking and data theft.
What the attacker needed
Ability to post a comment; victim views the comment
The fix
The platform should escape HTML and sanitise user-generated content, and use a Content Security Policy to prevent unauthorised script execution; the text says the company patched it but does not describe the fix.
How it was found
- Post a simple script tag in a comment on a public post and observe that it does not execute.
- Inspect the page's JavaScript files and notice that comments are processed using the DOM without proper escaping.
- Insert an image tag with an onerror handler into a comment and see the JavaScript execute when the image fails to load.
- Replace the alert with code that sends document.cookie to an attacker-controlled server via XMLHttpRequest.
- Have different users view the infected comment and confirm that session cookies are consistently stolen.
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.
When a website shows content that users type in, it must treat that content as plain text, not as code. Here, the site put user comments directly into the page without cleaning them, so a comment could contain a small piece of code that runs in other visitors' browsers. That code can then read the visitor's login cookie and send it to the attacker, letting the attacker log in as 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.