Your Vulnerability Is In Another OEM!
The login CGI binary on a Western Digital NAS copied the base64-decoded password into a fixed 120-byte stack buffer without bounds checking, so an unauthenticated attacker could overflow the stack and redirect execution. Because the binary lacked stack canaries and PIE, the authors showed a single-shot ROP chain that reaches a system() call and achieves remote code execution.
Published on synacktiv.com
Rédigé par Lucas Georges, Julien Boutet, Thomas Chauchefoin - 02/09/2021 - dans Exploit, Reverse-engineering - Téléchargement
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 authentication routine used an unbounded string copy of the decoded password into a 120-byte stack buffer, and the base64 decode was also given the wrong output size limit.
Impact
An unauthenticated attacker on the network could achieve remote code execution on the NAS, although the authors note the vulnerable code was removed by a major OS update days before the contest.
What the attacker needed
Network access to the NAS webserver; no authentication needed
How it was found
- Unpack the NAS firmware and list the exposed services, noting the Apache webserver and CGI binaries.
- Read the CGI dispatcher to see that unauthenticated users can only reach the login handler.
- Inspect the login routine and spot the unbounded copy of the decoded password into a 120-byte stack buffer.
- Send a long password to overflow the buffer and confirm control of the instruction pointer.
- Build a single-shot ROP chain using gadgets in the non-PIE binary to call system() with a controlled argument.
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 NAS is a small storage server on a home or office network. Its login program took the password you type, decoded it, and copied it into a fixed-size box in memory without checking the length. Sending a very long password spills past that box and overwrites the address the program will jump to next, letting an attacker choose which code runs.
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.