Write Once, Shell Everywhere: Turning Arbitrary File Writes into RCE
This is a research talk write-up about turning arbitrary file writes into remote code execution, cataloguing known execution sinks and proposing a technique that uses write errors as a path-probe oracle to fingerprint the target. An attacker with a file write could learn the OS, container runtime, language and version, then pick a destination that is actually executed.
ethiack.com
Published on ethiack.com
Some of the most under-rated findings we come across during our bug bounty engagements look exactly like this:
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
Likely the underlying issue is an application that lets user-controlled input decide both the path and the content of a written file, with no restriction on where it lands.
Impact
An attacker with such a write could achieve remote code execution if they can find a destination the target executes, though many techniques depend on root, a cron daemon, SSH or a restart that cloud-native containers often lack.
What the attacker needed
Attacker controls file path and content; a destination the target executes; often root or a restart trigger
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.
An arbitrary file write is a bug where an attacker can make the server save a file of their choosing at a location of their choosing. To get code execution, the attacker needs to drop that file somewhere the system will later run it, such as a startup script or a web-served folder. This talk maps out which of those locations exist and shows how error messages from failed writes can reveal what the server is running.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.