Insecure Upload
Source + configuration reviewA public image gallery saves whatever it receives. When an uploaded PHP file lands inside an executable web directory, a feature for sharing pictures becomes a way to run server-side code.
- 1. Public upload
POST /process_upload.phpThe form advertises images; the file field is named image. - 2. Unchecked storage
uploads/ + original basenameNo extension, MIME, or image-content policy is enforced. - 3. Data becomes code
GET /uploads/probe.phpApache's inherited PHP handler interprets the uploaded file. - 4. Service-account access
/var/www/flag.txtThe web process can read a file that HTTP cannot serve directly.
The scenario
BrightSpark Marketing runs a public community gallery. Visitors submit campaign images through upload.php; process_upload.php stores the files, and gallery.php exposes them through direct links and image requests.
The form's “JPG, PNG, GIF” promise is not implemented on the server. A valid multipart upload of a .php file follows the same storage path as an image. Because the upload directory retains PHP handling, a subsequent HTTP request can execute that file with the web worker's permissions.
The intended exercise is to identify the weak upload policy, establish server-side execution, and read a training flag outside the document root. No database, stolen account, reverse connection, or privilege escalation is needed.
What was reviewed—and what was not run
The supplied PHP, HTML, CSS, Apache configuration, Dockerfile, Compose file, and Markdown documentation were read as text. Public OWASP, PHP, Apache, and official PHP-image source were consulted for technical corrections. No container was built or started, no local page was opened, no payload was created or uploaded, and no supplied code was executed. All outputs here are source-derived or author-reported, not results of a live test.
What a complete solve means
- Identify the upload endpoint, multipart field, storage directory, and returned URL.
- Explain why browser file selection is not a server-side security boundary.
- Separate upload acceptance from proof that the saved file is interpreted as PHP.
- Explain the web worker's access to the flag without confusing it with root privileges.
- Keep evidence of the intended exploit separate from simply reading the answer in author files.
The central failure
Untrusted content is written into a web-accessible directory where the interpreter still runs.
The central distinction
Not publicly browsable does not mean unreadable to the application process.
Reveal the source-defined flag and location
The Dockerfile creates this literal value during a build. It is also disclosed in the author documentation and the public developer-notes source. This review did not build the image or retrieve a flag from a running service.
FLAG{insecure_file_upload_rce}Intended filesystem location: /var/www/flag.txt. Intended ownership: root:www-data. Mode: 0440.