Pwn2Own: Pivoting from WAN to LAN to Attack a Synology BC500 IP Camera, Part 2
A stack buffer overflow in the JSON parsing routine of the Synology BC500 IP camera's CGI binary allows an unauthenticated remote attacker to overwrite a function pointer and execute arbitrary code. The attacker can then gain a reverse shell and full control over the camera.
claroty.com
Published on claroty.com
Inpart one of this two-part series, we explained the first half of Team82’s WAN-to-LAN pivot attack whereby we gained access to TP Link ER605 routers, using a chain of exploits to bypass NAT protection and gain remote code execution on the router.
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 JSON parsing library on the camera uses an unsafe sscanf call that copies user-supplied key data into fixed-size stack buffers without bounds checking, leading to a stack buffer overflow.
Impact
An unauthenticated remote attacker could execute arbitrary code on the camera, leading to a reverse shell and full control, though ASLR required brute-forcing addresses and the exploit was used in a contest.
What the attacker needed
Network access to the camera; no authentication required
The fix
Synology fixed the vulnerability in firmware version 1.0.7-0298.
How it was found
- Send a PUT request to /syno-api/activate with a JSON body containing a key with two long strings separated by a space.
- The sscanf call splits the key into two buffers on the stack, overflowing them.
- Overflow continues until the get_func function pointer in the stream_t struct is overwritten with the address of the system function.
- The program later calls lex_scan, which invokes the overwritten pointer, executing the system function with a command from the heap.
- The heap is sprayed with the command to increase reliability, and null bytes are injected via the sscanf format.
- The payload is encoded in UTF-8 to bypass JSON key restrictions, and the exploit yields a reverse shell.
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 interface has a bug in how it reads a certain type of input (JSON). If an attacker sends a specially crafted request, they can overflow a small memory area and take control of the camera, running their own commands. This is dangerous because it can be done without logging in.
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.