Skip to content
XSS Write-up Intermediate

Stored XSS via PDF lead to One-Click Account Takeover

A PDF upload endpoint accepted files containing JavaScript that executed when opened in the app's PDF viewer, allowing an attacker to steal a victim's session cookie. The stolen session could then be used to change the victim's email and password, leading to account takeover.

mrdesoky0 Follow

Published on medium.com

Hello — I’m Desoky (mrdesoky0). I’ve been a bug hunter for about a month, and I used to be an Android developer for ~2.5 years.

mrdesoky0, on medium.com

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 PDF viewer (PDF.js) was vulnerable to arbitrary JavaScript execution via a font rendering flaw, and the upload endpoint did not sanitise or block such PDFs.

Impact

An attacker could steal a victim's session cookie and use it to change the victim's email and password, achieving one-click account takeover.

What the attacker needed

Victim opens the malicious PDF in the app viewer; attacker has an account to upload the PDF; victim is authenticated

The fix

The vulnerability was fixed, though the text does not describe the specific fix.

How it was found

  1. Generate a PDF with an XSS payload.
  2. Upload the generated PDF to the app's PDF upload endpoint.
  3. Open the uploaded PDF inside the app viewer as another authenticated user.
  4. Use a payload to send the cookie to an external server and confirm receipt.
  5. Use the stolen session to access authenticated-only endpoints.
  6. Find an endpoint that allows changing the user email while a valid session is present and change the email to one you control.

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.

A PDF file can contain JavaScript that runs when the file is opened in a viewer. The app did not check the PDF properly, so a malicious PDF could run code in the victim's browser and steal their login session. With that session, the attacker could change the victim's email and password.

What is XSS?

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.