The Casablanca Camera Caper
GoAhead web server decoded a null byte in the URL path, so a request for a file with a .html extension would actually serve a file without that extension, while still invoking the handler for the .html extension. An attacker could upload a file with a dangerous extension (like .jst) and then access it as if it were .html, bypassing extension-based security controls.
luker983.github.io
Published on luker983.github.io
I had the privilege of testing problems for PlaidCTF 2021, where I spent a decent amount of time on the Carmen Sandiego series of challenges. The basic premise is that the player can manipulate sensor and camera snapshot values that are visible to an admin on the web interface.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
The server decoded a null byte in the URL path, causing the extension used for handler selection to differ from the extension of the file actually served.
Impact
An attacker could bypass extension-based handler restrictions, potentially leading to code execution if they can upload a file with a dangerous extension and access it as a safe one; however, the exploit required a specific configuration (upload to a directory served by the JST handler) and was blocked in Chrome due to its URL parsing.
What the attacker needed
Ability to upload files to a directory served by the…; a browser that allows encoded null bytes in URLs (not…
The fix
The server was patched to not decode %00 to NULL, so the filename matches the URL and the extension is consistent.
How it was found
- Upload a file with a name that has no extension (e.g., 'example') containing JavaScript template code.
- Request the file with a null byte and a .html extension in the URL (e.g., /data/snapshot/example%00.html).
- Observe that the server processes the file as if it had a .html extension, executing the template code.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
A web server uses the file extension (like .html or .jst) to decide how to process a file. If an attacker can upload a file with a dangerous extension but trick the server into treating it as a safe extension, they can run code. Here, a null byte in the URL caused the server to see one extension for processing but a different one for fetching the file.
What is Path traversal?
Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.