Unauthenticated arbitrary file upload on the https://█████/ (█████████)
An upload endpoint accepted files and stored them in a publicly accessible location. An attacker could upload arbitrary content, potentially leading to stored XSS, hosting malicious files, or code execution.
- Triaged in 1 hour
- Fixed in 53 days
- Disclosed after 4.9 years
##Description I was able to identify unsafe upload endpoint on the https://█████/upload.php
##POC
- Go to the https://█████████/upload.php
- Upload some test file.
You will see success message:
████
3) Visit https://███/delete.me and you will see your uploaded file there
I uploaded example test file with string test file
█████████
Impact
Arbitrary file upload, may lead to the Stored XSS, hosting attacker's content and code execution.
What the report shows
The target is a host in the U.S. Department of Defence programme. and the feature under examination is an upload endpoint at upload.php. The researcher reported an unsafe upload endpoint there. rated high severity and classified as a violation of secure design principles. The report was disclosed on 16 August 2024.
The reproduction is short and direct:
- Go to the upload page:
https://█████████/upload.php
-
Upload some test file. The server answers with a success message:
-
Visit the path where the file landed:
https://███/delete.me
The uploaded file is served from that location. The researcher used a test file containing the string test file to demonstrate it:
test file
The report does not describe the request itself (method, multipart body, field names or headers), does not name the server software or version, and gives no fix, bounty amount or CVSS score. What it establishes is that the endpoint accepts a file and that the file is afterwards retrievable at a known URL.
Root cause
The likely cause is that the upload handler accepts and stores a file and that the stored file is placed in a web-served directory. The report does not show the handler's code, so the exact validation gap is not confirmed.
Impact
The report lists the consequences with hedges: arbitrary file upload, which "may lead to" stored XSS, hosting of attacker content, and code execution. Each depends on how the uploaded file is handled. The report says the upload may lead to stored XSS, without describing the mechanism. The report says the upload may lead to code execution. The report also mentions hosting of attacker content as a possible consequence. The report does not demonstrate any of these beyond retrieval of a plain text file.
How this kind of bug works
An arbitrary file upload exists when an application accepts a file from a user and stores it somewhere it can later be reached, without sufficiently constraining who may upload, what may be uploaded, or how the result is served. Three independent controls are usually missing or weak:
- Identity: the endpoint does not require a session or role, so anyone who can reach it can write files.
- Content: the extension, MIME type and actual bytes are not checked against an allowlist, so executable or renderable types get through.
- Serving: the stored file is placed inside the web root and served directly, often with a type derived from its extension, instead of being kept outside the document root and delivered through a handler that forces a safe content type and
Content-Disposition: attachment.
When all three fail, the upload becomes a write primitive into a web-accessible location. The severity then depends on the server: a directory that executes scripts turns it into code execution; a directory that serves HTML turns it into stored XSS on that origin; anything else turns it into content hosting.
How to test for it
- Find the endpoints. Look for upload features in the application (avatars, attachments, imports, document previews) and for orphaned scripts left in the web root, such as
upload.php,upload.aspx,fileupload,attach, and similar names, which are often reachable without a session even when the main application is not. - Test unauthenticated first. Send the upload with no cookies and no authorization header. A success response without a session is the strongest signal.
- Probe the constraints. Upload a harmless text file and note the returned URL or identifier. Then try a file with an unexpected extension, a mismatched
Content-Type, a double extension, and a name containing path traversal sequences. Record which are accepted and under what stored name. - Fetch the result. Request the stored URL and inspect the response headers: the
Content-Type, whetherContent-Dispositionis set, and whether the body is returned verbatim. A text file returned astext/htmlis already a stored XSS candidate. - Confirm execution only within scope. If the directory appears to execute scripts, use a minimal proof that does not damage the host, and stop there.
Common false positives: the file is stored but served only through an authenticated download handler; the extension is rewritten to something inert; the content type is forced to application/octet-stream with an attachment disposition; or the upload succeeds but the file is never retrievable. A success message alone proves nothing; retrieval with the right headers is what matters.
How it is fixed
- Require authentication and an authorisation check on the upload endpoint, and tie stored files to the uploading account.
- Validate against an allowlist of extensions and content types, and verify the actual file content rather than trusting the client-supplied type.
- Generate the stored filename server-side; never use the client's name for the path.
- Store files outside the web root and serve them through a handler that sets a safe
Content-TypeandContent-Disposition: attachment, ideally from a separate domain. - Disable script execution in any directory that must hold user content.
Hunting notes
Upload bugs cluster in older or auxiliary applications: standalone PHP or ASP scripts, admin panels, CMS plugins, and endpoints referenced by the front end but no longer linked in navigation. Recon signals include directory listings, predictable upload paths, error messages naming the handler, and JavaScript that posts to an upload URL. Because the impact hinges on how files are served, always retrieve the uploaded file and capture the response headers as evidence; that turns a bare success message into a demonstrable finding and makes the report far easier for a programme to accept.
What happened, in plain words
A security researcher found a page on a U.S. Department of Defence host with an unsafe upload endpoint. The page is called upload.php. Once a file is uploaded, it can be fetched again from a known address. The report was rated high severity, classified as a violation of secure design principles, and disclosed on 16 August 2024.
Think of it like a hotel front desk that hands out room keys to anyone who walks in, without asking for a name or a booking. The desk does not check who you are, and it does not check what you are carrying into the room. Here, the "desk" is a script on a web server, and the "room" is a folder that the web server will happily hand back to anyone who asks for the file by name.
A few terms first, because the rest of the report depends on them:
- A web server is the computer that stores a website and sends its pages to your browser when you visit an address.
- An endpoint is a specific address on that server that does one job, such as a page that accepts a form.
- Authentication means proving who you are, usually by logging in. Unauthenticated means the action works without logging in at all.
- An upload is when your browser sends a file from your computer to a website, for example a profile picture.
What the report shows
The researcher describes the problem in one line: an unsafe upload endpoint exists at upload.php on the target host. The reproduction is three steps.
- Go to the upload page:
https://█████████/upload.php
This is the address of the upload form. The point of visiting it is simply to confirm the page exists and is reachable.
- Upload some test file. The server answers with a success message:
The success message matters because it tells you the server accepted the file rather than rejecting it. A form that shows an error, or redirects you to a login page, would mean the upload did not go through. Here the server took the file.
- Visit the path where the file landed:
https://███/delete.me
This is the step that turns a vague success message into a real finding. The researcher uploaded a file and then fetched it back from a known address, showing the file is stored and retrievable.
The test file contained a single string:
```text
test file
That is deliberately harmless. The researcher uploaded a test file containing a harmless string, enough to show a file can be written and read back. The report does not describe the upload request itself (the HTTP method, the form fields, the headers), does not name the server software or its version, and gives no fix, bounty amount or CVSS score.
Why this is a problem
The report lists the possible consequences carefully, using the phrase "may lead to": stored XSS, hosting of attacker content, and code execution. Each depends on how the server treats the uploaded file.
- Stored XSS. XSS stands for cross-site scripting: tricking a browser into running code that came from someone else. "Stored" means the malicious content is saved on the server and served to later visitors. The report says the upload may lead to stored XSS, without describing the mechanism.
- Hosting attacker content. The report also mentions hosting of attacker content as a possible consequence. That borrowed trust is the valuable part.
- Code execution. The report says the upload may lead to code execution. That is the most serious outcome.
The report demonstrates none of these beyond fetching back a plain text file. That is normal and good practice: prove the flaw exists, describe the possible impact, and stop.
In general, how this kind of bug works
An arbitrary file upload happens when a website accepts a file from a user and stores it somewhere it can later be reached, without properly limiting who may upload, what may be uploaded, or how the result is served. Three separate controls are usually missing or weak:
- Identity. The endpoint does not require a login or a particular role, so anyone who can reach the page can write files.
- Content. The file's extension (the part after the dot, such as
.jpg), its declared type, and its actual bytes are not checked against a list of allowed kinds, so executable or renderable files get through. - Serving. The stored file sits inside the folder the web server publishes, and is handed out directly, often with a type guessed from its extension. A safer design keeps uploads outside that folder and delivers them through a handler that forces a harmless type and tells the browser to download rather than display.
When all three fail, the upload becomes a way to write files into a place the whole internet can read. The severity then depends on the server: a folder that runs scripts turns it into code execution, a folder that serves HTML turns it into stored XSS on that address, and anything else turns it into content hosting.
In general, how to test for it
- Find the endpoints. Look for upload features in the application (avatars, attachments, imports, document previews) and for leftover scripts in the web root, such as
upload.php,upload.aspx,fileupload,attachand similar names. These are often reachable without a session even when the main application is not. - Test unauthenticated first. Send the upload with no cookies and no authorization header. A cookie is a small piece of data your browser stores for a site, and it is how a logged-in session is usually recognised. A success response without a session is the strongest signal.
- Probe the constraints. Upload a harmless text file and note the returned URL or identifier. Then try a file with an unexpected extension, a mismatched
Content-Type, a double extension, and a name containing path traversal sequences (characters such as../that try to climb out of the intended folder). Record which are accepted and under what stored name. - Fetch the result. Request the stored URL and inspect the response headers. Headers are the extra lines of information a server sends before the page body. Check the
Content-Type(what kind of file the server claims it is), whetherContent-Dispositionis set (which can tell the browser to download instead of display), and whether the body comes back unchanged. A text file returned astext/htmlis already a stored XSS candidate. - Confirm execution only within scope. If the folder appears to run scripts, use a minimal proof that does not damage the host, and stop there.
Common false positives: the file is stored but only downloadable through a login-protected handler; the extension is rewritten to something inert; the content type is forced to application/octet-stream with an attachment disposition; or the upload succeeds but the file is never retrievable. A success message alone proves nothing; retrieval with the right headers is what matters.
In general, how it is fixed
- Require authentication and an authorisation check on the upload endpoint, and tie stored files to the uploading account.
- Validate against an allowlist of extensions and content types, and verify the actual file content rather than trusting the type the client claims.
- Generate the stored filename on the server; never use the client's name for the path.
- Store files outside the published web folder and serve them through a handler that sets a safe
Content-TypeandContent-Disposition: attachment, ideally from a separate domain. - Disable script execution in any folder that must hold user content.
In general, where to look
Upload bugs cluster in older or auxiliary applications: standalone PHP or ASP scripts, admin panels, CMS plugins, and endpoints referenced by the front end but no longer linked in navigation. Useful signals include directory listings, predictable upload paths, error messages that name the handler, and JavaScript that posts to an upload URL. Because the impact hinges on how files are served, always retrieve the uploaded file and capture the response headers as evidence. That turns a bare success message into a demonstrable finding and makes the report far easier for a programme to accept.
Glossary
- Authentication: proving who you are, usually by logging in.
- Authorisation: deciding what a proven user is allowed to do.
- Unauthenticated: usable without logging in.
- Endpoint: a specific address on a server that performs one job.
- Web server: the computer that stores a website and sends its pages to browsers.
- Upload: sending a file from your computer to a website.
- Arbitrary file upload: a flaw that lets a user upload a file of any kind, often without a login.
- Web root: the folder on a server whose contents are published to the internet.
- Extension: the part of a filename after the dot, such as
.jpg, which hints at the file type. - MIME type / Content-Type: a label describing what kind of file something is, such as
text/html. - Content-Disposition: a response header that can tell the browser to download a file instead of displaying it.
- Response header: extra information a server sends before the page body.
- Cookie: a small piece of data a browser stores for a site, often used to recognise a logged-in session.
- Session: a logged-in state a site remembers across requests.
- Stored XSS: cross-site scripting where malicious content is saved on the server and served to later visitors.
- Code execution: making a server run code the attacker supplied.
- Path traversal: using sequences such as
../in a filename to try to reach folders outside the intended one. - Allowlist: a list of things that are permitted, with everything else rejected.
- False positive: a result that looks like a vulnerability but is not one in practice.
- CVSS: a standard scoring system for rating the severity of a vulnerability.