Foscam IP Video Camera WebService CGI Parameter Code Execution Vulnerability
The web management service of the Foscam C1 camera copies user-supplied query parameters into fixed 64-byte stack buffers without checking their length. An attacker could send a crafted HTTP request to overflow the stack and overwrite the saved return address, potentially leading to code execution on the device.
Originally disclosed on Cisco Talos
An exploitable stack-based buffer overflow vulnerability exists in the web management interface used by the Foscam C1 Indoor HD Camera. A specially crafted http request can cause a stack-based buffer overflow resulting in overwriting arbitrary data on the stack frame.
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 report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The parameter extraction routine copies bytes from the query into a caller-supplied buffer until '&' or end of string, without being told the destination buffer's size, so a long value overflows the 64-byte stack buffers.
Impact
An attacker could overwrite stack data and the saved return address, potentially achieving code execution on the camera with a single unauthenticated HTTP request.
What the attacker needed
Network access to the camera's web interface; no authentication required
How it was found
- Send an HTTP request to the camera's CGI proxy endpoint with the cmd, pwd and usr parameters set to oversized values.
- Overflow the usr parameter past its 64-byte buffer to overwrite the function pointer variable, stack frame padding and the saved link register.
- Supply a chosen 32-bit address for the link register so the device reboots cleanly, demonstrating control of execution.
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 report has not been written yet. The Original tab links to the source.
The camera's web service reads values from the URL and copies them into small fixed-size boxes in memory without checking how long they are. If a value is longer than the box, it spills over into neighbouring memory, including the place that records where the program should return to. An attacker who controls that spilled data can redirect the program, which is how memory corruption can become code execution.
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.