Bug Bounty Cheat Sheet: File Upload Extension Splitting

Listen to this Post

Featured Image

Introduction:

File upload vulnerabilities are a common attack vector in web applications, often leading to remote code execution (RCE) or server compromise. Attackers exploit improper validation of file extensions to bypass security controls. This article explores extension splitting techniques, verified commands for testing, and mitigation strategies.

Learning Objectives:

  • Understand how file upload extension splitting bypasses security filters.
  • Learn practical commands to test for this vulnerability.
  • Implement secure file upload validation in web applications.

1. Basic Extension Splitting

Command (Linux/Bash):

mv malicious.php exploit.php.jpg

How It Works:

  • Renames a PHP shell (malicious.php) to mimic an image file (exploit.php.jpg).
  • Some systems only check the last extension (.jpg), allowing execution if the backend processes .php.

Testing Steps:

1. Upload `exploit.php.jpg` to the target server.

  1. If the server strips or ignores .jpg, the file may execute as .php.

2. Null Byte Injection

Command (Python Exploit):

filename = "shell.php%00.jpg"

How It Works:

  • The `%00` (null byte) tricks the server into terminating the filename string early, ignoring .jpg.
  • Works on poorly sanitized systems.

Testing Steps:

  1. Use Burp Suite to intercept a file upload request.
  2. Modify the filename to include `%00` before the fake extension.

3. Double Extension Bypass

Command (Windows CMD):

ren payload.php payload.php.png

How It Works:

  • Uploads a file with dual extensions (e.g., file.php.png).
  • If the server checks only the first extension (png), the `.php` may still execute.

4. Case Manipulation

Command (Linux):

mv exploit.php Exploit.PHp

How It Works:

  • Evades case-sensitive filters (e.g., `.php` vs .PHp).
  • Common on Windows servers where extensions are case-insensitive.

5. MIME Type Spoofing

Burp Suite Intercept Snippet:

Content-Type: image/jpeg

How It Works:

  • Overrides the actual file type by spoofing the MIME header.
  • Upload a PHP file with `image/jpeg` header to bypass client-side checks.

6. .htaccess Exploitation

Command (Linux):

echo "AddType application/x-httpd-php .jpg" > .htaccess

How It Works:

  • Forces the server to treat `.jpg` files as PHP executables.
  • Upload `.htaccess` + a `.jpg` shell to gain RCE.

7. Cloud Storage Bypass (AWS S3 Example)

AWS CLI Command:

aws s3 cp malicious.php s3://bucket/exploit.php%00.jpg --content-type "image/jpeg"

How It Works:

  • Exploits misconfigured S3 buckets to upload executable files.

What Undercode Say:

  • Key Takeaway 1: File upload vulnerabilities often stem from flawed validation logic—always sanitize both filenames and content.
  • Key Takeaway 2: Combine multiple techniques (e.g., null bytes + MIME spoofing) for higher success rates in bug bounty tests.

Analysis:

Extension splitting remains a critical flaw in web apps due to inconsistent server-side checks. As AI-driven security tools evolve, attackers adapt with polymorphic payloads. Future-proof defenses require:
1. Multi-layered validation (extension + content + signature checks).

2. Sandboxed upload directories with restricted permissions.

3. Real-time monitoring for anomalous file executions.

Prediction:

By 2025, 60% of file upload exploits will target serverless architectures (e.g., AWS Lambda), demanding new hardening frameworks.

Test these techniques only on authorized systems. Unauthorized hacking is illegal.

IT/Security Reporter URL:

Reported By: Therceman Bug – Hackers Feeds
Extra Hub: Undercode MoN
Basic Verification: Pass ✅

🔐JOIN OUR CYBER WORLD [ CVE News • HackMonitor • UndercodeNews ]

💬 Whatsapp | 💬 Telegram

📢 Follow UndercodeTesting & Stay Tuned:

𝕏 formerly Twitter 🐦 | @ Threads | 🔗 Linkedin