Unrestricted File Upload Leads to Stored XSS, SSRF, and Phishing
The application accepts uploaded PDF files without proper validation, allowing an attacker to embed JavaScript that executes when the PDF is opened. This can lead to stored XSS, SSRF, and phishing attacks.
medium.com
Published on medium.com
Improper validation and sanitization of user-uploaded files allows attackers to upload malicious PDF files containing embedded JavaScript.
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
The application fails to validate or sanitise uploaded PDF files, trusting them to be safe and serving them directly to users or rendering them with a built-in viewer.
Impact
An attacker could execute arbitrary JavaScript in the context of the application's domain, leading to cookie theft, session hijacking, or further client-side attacks; they could also perform blind SSRF to access internal services or exfiltrate server-side files, and redirect users to phishing pages.
What the attacker needed
Ability to upload PDF files; Victim opens the uploaded PDF
The fix
File uploads should always be treated as untrusted input, regardless of file type, and should be properly validated and sanitised.
How it was found
- Generate a malicious PDF using the jspdf module with embedded JavaScript.
- Upload the crafted PDF to the vulnerable website.
- When a victim opens the PDF, the embedded JavaScript executes automatically.
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 code that runs when the file is opened in a viewer. If a website lets people upload PDFs and then shows them to other users, an attacker can upload a PDF with harmful JavaScript. This code can steal cookies, make the server send requests to internal systems, or redirect users to fake login pages.
What is File upload?
An upload feature accepts a file that the server or other users' browsers then treat as code or as something trusted.