File upload vulnerabilities are common in CTFs and can lead to remote code execution. Learn the techniques to bypass filters and upload malicious files.
File uploads are high-value targets. A successful bypass often means RCE!
Extension Bypasses
Servers often filter by extension. Try these bypasses:
Content-Type Bypass
Change the Content-Type header to bypass MIME checks:
Magic Bytes
Some servers check file signatures. Prepend magic bytes:
The file might still execute as PHP even with image magic bytes at the start.
Polyglot Files
Create files that are valid as both an image and PHP:
Polyglots work when the server validates file content but executes based on extension.
.htaccess Tricks
If you can upload .htaccess files:
Key Takeaways
- Try multiple extension bypasses: double, case, alternative
- Spoof Content-Type header in upload requests
- Use magic bytes to bypass signature checks
- Polyglot files can pass validation but execute as code
- .htaccess uploads can change how files are processed