From Profile Picture to Account Takeover: Stored XSS in Action
A WordPress site allowed users to upload SVG files as profile pictures without sanitising embedded JavaScript. An attacker could upload a malicious SVG that executes script when viewed, stealing cookies and other data to take over accounts.
medium.com
Published on medium.com
Cross-Site Scripting (XSS) remains one of the most common — yet impactful — vulnerabilities on the web today. While often associated with simple alert(1) proof-of-concepts, a real-world XSS bug can lead to severe consequences such as session hijacking, privilege escalation, or full account takeover.
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 accepted SVG uploads and served them from a first-party path without sanitising or sandboxing the embedded script content.
Impact
Whenever a user, including an administrator, viewed the uploaded SVG, their cookies and other data could be stolen, potentially leading to account takeover.
What the attacker needed
A user account with profile picture upload; victim views the uploaded SVG
The fix
The site should treat SVGs as executable content and either disallow direct SVG uploads or pass them through strict sanitisation before serving.
How it was found
- Upload a standard PNG profile picture and note the public upload path.
- Test uploading a basic SVG file to see if it is accepted.
- Upload an SVG containing a script that shows an alert to confirm execution.
- Access the uploaded SVG in the browser and observe the alert.
- Replace the alert with a script that exfiltrates cookies and other data to an external server.
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 upload a picture file, but it didn't check what was inside. A picture format called SVG can contain code, so the uploaded file ran code in the browser of anyone who looked at it. That code could steal the viewer's login cookies.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.