Cybernetics

Diagnostic playbook

Unrestricted file upload (arbitrary file upload / RCE potential)

Web / File Upload

Knowledge identity

Definition and taxonomy

Summary

The upload endpoint does not validate file content/extension. Any file can be stored under the web root and, for scripting extensions, executed by the server.

Severity rationale

Demonstrated uploading a PHP file with no validation (low) and with a spoofed image/png Content-Type (medium) and executing it over HTTP (server returned the PHP output). In a real app this is direct remote code execution.

Aliases

Arbitrary file upload, webshell upload, unrestricted upload

Standards

CWE-434 CAPEC-650 A03:2021-Injection

CVSS vector

CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H

1. First Signal

What should make an agent suspicious

Symptoms

A .php file is accepted and its output is returned when fetched; at medium the same file is rejected as text/plain but accepted when the client sends Content-Type: image/png; at high only real images pass.

Prerequisites

Authorized lab session. Upload endpoint stores files under web root without content validation.

2. Recognition Logic

How to recognize this next time

If an upload endpoint echoes success and the target dir is web-accessible, test whether a .php probe executes. If it checks MIME type, spoof the client Content-Type header. If it checks getimagesize/extension, a naive polyglot is rejected.

3. Diagnostic Procedure

Safe checks, in order

  1. Confirm authorized scope. 2. Upload an inert text file, then an inert PHP probe (echo only). 3. Verify the uploaded file is web-accessible and whether it executes. 4. If MIME-gated, resend with a spoofed Content-Type. 5. Do not upload a real webshell; use a harmless echo probe and remove/limit to the authorized lab.

4. Proof

Evidence

DVWA upload: low accepted probe.php (up_probe_ok served over HTTP); medium rejected text/plain php but accepted the same file with type=image/png and served it; high rejected php and a naive polyglot, accepted only a genuine PNG.

5. Controls

Negative checks

At medium, the same .php with text/plain was rejected (control proving MIME is the only gate). At high, .php and a php-prefixed PNG signature were both rejected.

6. Avoid Bad Memory

False positives and traps

A successful upload of a non-executable file is not RCE; the file must be stored under the web root and served/executed. MIME rejection without a bypass is not the same as real validation.

7. Why It Matters

Impact

Uploading an executable script gives remote code execution on the server as the web user; full compromise in a real deployment.

8. Why It Happened

Root cause

No content validation on upload at low; medium trusts client-supplied MIME type; high validates extension and getimagesize (robust against naive bypass).

9. Fix

Remediation and prevention

Validate file extension allowlist AND file content (magic bytes/getimagesize) AND stored filename (server-generated). Serve uploads from a non-executable directory or with Content-Disposition. Scan for malware.

10. Re-test

Verification steps

  1. After fix, upload a .php probe and confirm rejection. 2. Upload a real image and confirm it is stored under a non-executable path or served as download. 3. Confirm no script executes from the uploads dir. 4. Add regression tests.

Reference

Tools and sources

Tools used

curl for multipart uploads, docker exec for read-only source review

References

OWASP File Upload Cheat Sheet; CWE-434; CAPEC-650

Intelligence

Products and history

Technologies

PHP, Apache

Affected products / versions

DVWA (Damn Vulnerable Web Application) current master

History

First documented in DVWA upload module in the 2026-08 benchmark run.

Exploit knowledge

Variants and references

Attack surface

uploaded file field storing to hackable/uploads/ under the web root

Exploit maturity

proof-of-concept

Known variants

No validation (low), client-controlled MIME type spoof (medium), extension+getimagesize validation (high - resists naive bypass; advanced polyglot remains theoretical)

Defensive signatures

Multipart uploads with script extensions accepted, files appearing under the web root and returning script output, Content-Type header mismatched from actual file type

Reproduction commands

Low (no validation): printf '<?php echo "up_probe_ok"; ?>' > /tmp/probe.php curl -s -b $JAR -F "uploaded=@/tmp/probe.php;type=text/plain" -F "Upload=Upload" http://127.0.0.1:4280/vulnerabilities/upload/ curl -s -b $JAR http://127.0.0.1:4280/hackable/uploads/probe.php # up_probe_ok Medium (MIME spoof): curl -s -b $JAR -F "uploaded=@/tmp/probe.php;type=image/png" -F "Upload=Upload" http://127.0.0.1:4280/vulnerabilities/upload/ High (mitigated): curl -s -b $JAR -F "uploaded=@/tmp/probe.php;type=image/png" -F "Upload=Upload" http://127.0.0.1:4280/vulnerabilities/upload/ # not uploaded

Exploit references

No external references stored; all evidence from the authorized local lab. Only a harmless inert PHP probe (echo marker) was used.

Case provenance

Linked findings