Content-Type bypass: change Content-Type: image/jpeg in Burp
Magic bytes bypass: prepend GIF89a; to PHP shell content
Find upload destination path by reviewing source or using dirbusting
Access uploaded file to trigger code execution
If client-side validation only: disable JS or intercept with Burp
Limited upload (no web execution): use upload for LFI+RFI chain
π― Operational Context
Use when: File upload functionality exists β bypass extension filters, MIME type checks, and content validation to upload executable web shells.
Think Dumber First: First identify what the server accepts. Try renaming .php to .php5, .phtml, .phar. Change Content-Type header to image/jpeg. Add GIF header GIF89a; before PHP code. Try one bypass at a time.
Skip when: File upload is to S3/cloud storage with no execution path β stored XSS from uploaded SVG/HTML is the attack instead.
β‘ Tactical Cheatsheet
Command
Tactical Outcome
echo '<?php echo "Hello HTB";?>' > test.php
Benign PoC β verify execution before deploying shell
Check response body for file path; try common paths: /uploads/, /files/, /media/, /tmp/; use ffuf to find it
π Reporting Trigger
Finding Title: Unrestricted File Upload Enables Web Shell Deployment
Impact: Bypassing file upload restrictions allows deploying a PHP web shell on the server, providing persistent remote code execution in the web serverβs process context with access to all application data and internal network connections.
Root Cause: File upload validation implemented as a denylist of extensions or MIME types rather than strict allowlisting and content validation. Uploaded files stored within the web root with PHP execution enabled.
Recommendation: Allowlist only required file types. Validate file content, not just extension and MIME type. Store uploaded files outside web root with randomized names. Serve through a dedicated file serving endpoint without execution privileges.