From File Upload to Admin Account Takeover: Exploring Blind XSS v
A file upload feature stripped extensions and randomised filenames but did not validate file content or force safe delivery headers, so an uploaded file containing HTML/JavaScript was rendered and executed by the browser. Because session cookies lacked the HttpOnly flag, the script could read them, and when an administrator viewed the uploaded file in the backend dashboard, the attacker could exfiltrate the admin session.
In this write-up, I will walk through how a standard file upload feature on my university portal (sar.su.edu.ye) was leveraged to achieve Stored/Blind Cross-Site Scripting (XSS), ultimately leading to the extraction of sensitive administrator session cookies.
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 served user-uploaded files without a safe Content-Type or Content-Disposition header, allowing the browser to interpret the file as HTML and execute embedded script, and session cookies lacked the HttpOnly flag.
Impact
An attacker could hijack an administrator's session, leading to full account compromise, access to sensitive records, and unauthorised administrative actions.
What the attacker needed
Ability to upload a file; administrator views the uploaded file; cookies lack HttpOnly flag
The fix
The application should serve user-uploaded files with a safe Content-Type such as application/octet-stream and a Content-Disposition attachment header, set the HttpOnly flag on session cookies, and deploy a restrictive Content Security Policy.
How it was found
- Upload a file whose body contains an XSS trigger instead of image or text data.
- The server discards the original filename, assigns a random name, and strips the extension.
- Navigate to the randomised file URL; the browser parses the content as HTML and executes the script.
- An administrator views the uploaded file or activity log in the backend dashboard, causing the stored script to run in their session.
- The script reads document.cookie and sends it to an external listener.
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 website let people upload files. It changed the file name but did not check what was inside, and it served the file in a way that made the browser run any code in it as if it were a normal web page. When an administrator later opened that file, the hidden code ran in their browser and stole their login cookie, which is like a temporary key that keeps them logged in.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.