No Leak, No Problem – Bypassing ASLR with a ROP Chain to Gain RCE
An unauthenticated attacker could send an oversized HTTP Basic authentication header to a CGI endpoint, overflowing a fixed-size stack buffer in the Base64 decoding routine of the fcgi_server binary. This gave control of the return address and, by chaining ROP gadgets from the non-PIE binary, allowed bypassing ASLR without an address leak to reach command execution.
modzero.com
Published on modzero.com
After my previous post on ARM exploitation, where we crafted an exploit for a known vulnerability, I decided to continue the research on a more modern IoT target. In this follow-up post, I will take you through building a considerably more complex binary exploit.
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 a custom Base64 decoder copied the decoded Basic auth value into a fixed 516-byte stack buffer using memcpy without a length check.
Impact
An unauthenticated remote attacker could achieve command execution on the camera, though the exploit relies on a one-shot ROP chain and the crash is masked because lighttpd restarts the service.
What the attacker needed
Network access to the camera web interface; no authentication required; knowledge of the binary's gadgets
How it was found
- Extract the firmware by accessing the UART interface and interrupting U-Boot to boot with a shell as init.
- Map the web stack: lighttpd forwards .cgi requests to fcgi_server, which forwards to ipc_server over a socket.
- Reverse engineer fcgi_server and identify the Basic auth handler and its custom Base64 decode function.
- Set breakpoints and send a normal Basic auth request to confirm the decode path is reached.
- Send a Basic auth value longer than the 516-byte buffer and observe the crash with the program counter set to the payload pattern.
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.
The camera's web helper program copied a decoded login string into a small fixed box on its memory stack without checking the length. Sending a very long login value spilled past the box and overwrote the saved return address, which tells the program where to continue after a function finishes. The researcher then redirected that return into small existing code fragments to run commands, working around the random placement of shared libraries.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.