Chapter 6
Storage risks, serving flaws, and race conditions
How hosting misconfigurations and execution windows expose servers.
Where a file lands, and how the browser receives it back, often matters more than what passed the upload filter. Even a clean validation step falls apart if the storage bucket or response headers are sloppy.
Common storage and serving mistakes
Section titled “Common storage and serving mistakes”Check these four patterns whenever an upload returns a viewable URL.
Same-origin inline serving
Section titled “Same-origin inline serving”If the app serves user files inline from its main domain without a strict Content Security Policy, any .html or .svg upload becomes stored XSS. Because the file loads under the primary origin, scripts inside it inherit the victim’s session.
Executable upload folders
Section titled “Executable upload folders”Older setups still drop uploads straight into a public web root where script handlers stay turned on. Unless Apache or Nginx explicitly disables execution in that folder, requesting the uploaded URL runs it on the server.
Predictable object storage keys
Section titled “Predictable object storage keys”Moving files to Amazon S3, Google Cloud Storage, or Azure Blob Storage does not fix access control. If download URLs use sequential numbers, guessable keys, or signed URLs that never expire, test them for IDOR right away. The full identifier playbook sits in the IDOR guide.
Missing nosniff headers
Section titled “Missing nosniff headers”Without X-Content-Type-Options: nosniff, some browsers peek at the response bytes and ignore the server’s Content-Type. A plain text upload containing HTML can get rendered as a live web page instead.
Filename reflection in headers
Section titled “Filename reflection in headers”Applications frequently reflect original file names inside Content-Disposition or Content-Type response headers.
If the application fails to sanitize carriage returns or quote characters, attackers inject arbitrary HTTP headers.
The storage race window
Section titled “The storage race window”This is a Station 2 storage flaw, not a separate station. Some upload architectures write incoming files to disk before completing malware scans or content validation. The backend processing pipeline follows a sequence of store, scan, and delete actions.
Time Server activity Attacker activityt = 0 ms Server stores /uploads/avatar.php Upload request completest = 200 ms Antivirus scanning begins -t = 400 ms - Second thread sends GET /uploads/avatar.php?c=idt = 500 ms - Server responds with command outputt = 800 ms Scanner marks file malicious -t = 850 ms Server deletes file from disk -If a short time window exists between initial disk write and background deletion, concurrent requests can execute the file.
Exploiting the race condition
Section titled “Exploiting the race condition”Use Turbo Intruder or concurrent curl requests to exploit this window.
- Configure the first thread to send continuous multipart upload requests containing your web shell.
- Configure a concurrent pool of worker threads to request the predictable target path repeatedly.
- Monitor response bodies for successful command output.
- Stop the request threads immediately once proof of execution is obtained.
The underlying single-packet technique is the same one used against other store-then-check windows. See HTTP/2 single-packet race procedures for the verified Turbo Intruder script.
Pre-signed URL uploads
Section titled “Pre-signed URL uploads”Modern apps often skip the server for the upload body itself. The browser asks the backend for a pre-signed URL or a POST policy. The browser then sends the file straight to the object store. The backend only signs the request, so its validation never sees the bytes.
Two weaknesses follow from this design.
The first is a loose policy. If the signed policy does not pin the content type, the key prefix, and a size limit, the client chooses them. A client can store an HTML file, pick any key, or upload a huge object.
The second is a key path the client controls. If the backend signs a key built from client input, the client can point it at another user path. An upload then overwrites an object that belongs to someone else.
Test the policy in these steps.
- Request an upload URL and read the returned policy fields.
- Change the content type to
text/htmland confirm the store accepts it. - Change the object key to a path outside your own prefix.
- Confirm whether the signed policy rejects the change or honors it.
Upload from a URL
Section titled “Upload from a URL”Some endpoints accept a URL instead of a file body. An avatar import or a document fetch pulls the asset from an address you supply. The server makes the request, so you aim that request at internal infrastructure. This is server-side request forgery, known as SSRF, reached through the upload feature. See SSRF testing in Bug Hunting for Beginners for callback setup and IP-encoding bypasses.
POST /api/avatar/import HTTP/2Host: target.comContent-Type: application/json
{"image_url": "http://169.254.169.254/latest/meta-data/"}Probe the cloud metadata address, internal hostnames, and the loopback interface. Watch the stored asset, the error text, and the response time for signs the server reached your target.
Cache and CDN effects
Section titled “Cache and CDN effects”Uploaded files are often served through a cache or a content delivery network, known as a CDN. A file stored under a shared key can be served to the wrong user. A response cached without a type header can later render as HTML on the main origin.
Check the X-Cache, Age, and Vary headers on the served file.
A cache hit on a per-user asset is an information exposure finding on its own.
Next, Chapter 7 walks the full decision tree from validation through storage and serving.
Open local graph around this page
Linked from here
File UploadFor authorized testing only.