“Day 24: The Polyglot Poison — How I Turned a Resume Uplo
The upload feature accepted a file that was both a valid PDF and a PHP script, and the server later executed it as PHP. An attacker could upload such a file and run commands on the server.
Published on infosecwriteups.com
The target was a job recruitment platform. They allowed users to upload resumes, proudly displaying a banner: “All files are scanned for viruses!” I knew they’d be checking for .php and .exe extensions.
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 uploaded file was stored inside the web root with an executable extension, and the server executed it instead of serving it as a static file.
What the attacker needed
Ability to upload a file; server executes uploaded files
The fix
Uploaded files should be stored outside the web root and served with a non-executable extension or through a dedicated script.
How it was found
- Upload a plain PHP shell and observe rejection.
- Change the extension to .pdf.php and observe rejection.
- Change the Content-Type header to application/pdf and observe rejection.
- Upload a real PDF and observe acceptance.
- Create a polyglot file starting with a PDF header and containing PHP code in a PDF comment.
- Upload the polyglot file and access it directly to trigger command execution.
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 file upload feature let people send in resumes. The site checked the file type but was fooled by a file that was both a PDF and a PHP script. When the server later ran that file as a program, the attacker could run commands on the server.
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.