File upload security testing
Brief
Most upload findings come from the server trusting what the browser says about a file, or serving the file back from the app's own origin. Each check here uses a test account and a harmless file we made, so the result shows the gap without putting anything executable on the client's server.
Exam prep OSCP
On this page
- Situation
- A test account on the app, the upload points from the web app first hour, and the client's stated rules for each: types, size and who may see the file. Every file we upload is harmless and carries the marker ATARUS-TEST-2026-10-28 in its name: plain text, a small image we made, an HTML file with no script, and the EICAR antivirus test file. We never upload a script, a web shell or a crafted image aimed at a library flaw, and we delete every upload the same day with its id recorded. Only the applications the scope letter names are tested.
- Goal
- A table per upload point: what the server checks, where the file is stored and served from, with which headers, whether images are re-encoded, and whether size limits and scanning hold on the server.
- Outputs
- Captured on 4 Nov 2026 against the Atarus Bench Web and API lab fixture, edition
web-api-0.2, running on loopback, with one origin playing every host, renamed to the example domains and printed ashttps(the lab ran plainhttp). The image metadata output stays representative: exiftool is not on the bench, so that step was not run.
Check first
- Every upload point: profile pictures, attachments, imports, and API endpoints that take files.
- The rules the client states for each: allowed types, maximum size, and who can see the file afterwards.
- Where uploads are stored and served: the app's own server, object storage, or a separate domain.
- Which library processes images or documents, from the client's dependency manifest.
- The marker ATARUS-TEST-2026-10-28 in every file name, so each upload can be found and deleted.
Steps
Does the server trust the declared type and extension?
printf 'ATARUS-TEST-2026-10-28 plain text\n' > atarus-test-2026-10-28.png
curl -s -w '\n' -b "session=$TESTER_A_SESSION" -F 'file=@atarus-test-2026-10-28.png;type=image/png' \
https://app.example.com/api/files
printf '<p>ATARUS-TEST-2026-10-28</p>\n' > atarus-test-2026-10-28.html
curl -s -w '\n' -b "session=$TESTER_A_SESSION" -F 'file=@atarus-test-2026-10-28.html;type=image/png' \
https://app.example.com/api/files
Expected output
{"id":"f_test_0412","name":"atarus-test-2026-10-28.png","url":"/uploads/atarus-test-2026-10-28.png"} # <- text accepted as an image
{"id":"f_test_0413","name":"atarus-test-2026-10-28.html","url":"/uploads/atarus-test-2026-10-28.html"} # <- an .html name kept exactly as sent
The Content-Type of each part and the file name are both chosen by the client, so a server that checks either one is checking our claim, not the file. The first upload shows the server never read the content. The second shows it keeps our extension and our name, which decides how the file is served back in the next step.
Negative result. Both uploads refused with an error naming the allowed types, or stored under a name the server generated with a type it worked out from the content.
Fix. Allow a short list of extensions, check the file's content signature on the server, store every file under a generated id, and never use the client's file name in a path.
Where are uploads stored, and from which domain are they served?
curl -sI https://app.example.com/uploads/atarus-test-2026-10-28.html \
| grep -iE '^(content-type|content-disposition|x-content-type-options):'
curl -s -o /dev/null -w '%{http_code}\n' https://app.example.com/uploads/atarus-test-2026-10-28.png
Expected output
Content-Type: text/html; charset=utf-8 # <- rendered as a page on the app's own origin
200 # <- fetched with no session: anyone with the URL can read uploads
An HTML file rendered on the app's origin runs in the same origin as the user's session, so the next uploader can add a script where we added a paragraph; it is the stored form of the output contexts on the reflected XSS page. Neither Content-Disposition nor nosniff came back, and the second request carried no cookie. Whether files sit inside a web root that runs server-side code is a question for the client's configuration, which we read with them rather than test by uploading code.
Negative result. Files come from a separate domain with Content-Disposition: attachment, X-Content-Type-Options: nosniff and a type the server chose, and private files need a session or a short-lived signed URL.
Fix. Store uploads outside the web root or in object storage, serve them from a separate domain with those headers, and hand out short-lived signed URLs for private files.
Does image processing strip metadata?
exiftool -Comment=ATARUS-TEST-2026-10-28 -GPSLatitude=0 -GPSLongitude=0 atarus-test-2026-10-28.jpg
# uploaded as tester-a's profile picture through the app, then fetched back
curl -s -o served.jpg https://app.example.com/uploads/avatars/u_test_a.jpg
exiftool -Comment -GPSPosition served.jpg
Expected output
Comment : ATARUS-TEST-2026-10-28 # <- the file is served as uploaded, never re-encoded
GPS Position : 0 deg 0' 0.00" N, 0 deg 0' 0.00" E
We write our own marker and a zero location into our own photo. If both come back, the app stores what users send byte for byte, so customers' photos keep their real locations, and no image library touched the file. If the image is re-encoded, the metadata is gone and the library's version is the next question; we read that from the client's dependency manifest rather than probing it with crafted files.
Negative result. No comment and no location in the served image, and a current, supported library doing the re-encoding.
Fix. Re-encode every image on the server into a fixed format, strip metadata, keep the library current, run it in an isolated process with no network, and restrict ImageMagick through its security policy to the formats the app accepts.
Are size limits and malware scanning enforced on the server?
head -c 27262976 /dev/zero > atarus-test-2026-10-28-26mb.bin
curl -s -o /dev/null -w '%{http_code}\n' -b "session=$TESTER_A_SESSION" \
-F 'file=@atarus-test-2026-10-28-26mb.bin' https://app.example.com/api/files
curl -s -b "session=$TESTER_A_SESSION" -F 'file=@atarus-test-2026-10-28-eicar.txt;type=text/plain' \
https://app.example.com/api/files
Expected output
201 # <- 26 MB accepted against a stated 25 MB limit: the check lives only in the browser
{"id":"f_test_0415","name":"atarus-test-2026-10-28-eicar.txt","url":"/uploads/atarus-test-2026-10-28-eicar.txt"} # <- the antivirus test file was stored and served back
The browser enforced the limit in the page, so a direct request skipped it. The EICAR file is a short harmless string that every antivirus engine flags by design; if it is stored and downloadable a few minutes later, no scanner sits on this path. We delete uploads f_test_0412 to f_test_0415 through the app and reset the test profile picture before the end of the day.
Negative result. A 413 or a clear error for the large file, and the EICAR file refused or quarantined before anyone can download it.
Fix. Enforce size limits at the proxy and in the application, limit image pixel dimensions before decoding, scan every file before it becomes available, and refuse uploads when the scanner is down.
The defender sees
The app should log every upload with the user, the original name, the type it detected, the size and the stored id, which makes our test files easy to find by their marker. The EICAR upload should raise an antivirus alert naming the test account; if nothing fired, that is a finding on its own. A web application firewall sees a 26 MB multipart body and an .html upload, and a CDN or server log shows the unauthenticated fetch of a private file. If the client cannot find our uploads by the marker, the upload log is missing.
Done when
Each upload point has a result for type and name handling, the serving domain and headers, metadata handling, the server-side size limit and the antivirus test file, and every test upload is deleted with its id in the notes.
Not covered
Upload of executable code, parser exploits against image or document libraries, archive extraction flaws, and other users' files by guessed URL (see IDOR testing).