ArduPilot APWeb cgi.c unescape memory corruption vulnerability
The unescape function in APWeb's cgi.c assumes every percent sign is followed by two hex characters, so a crafted HTTP request ending in a bare percent sign causes an out-of-bounds read and write. An attacker sending such a request over the network could corrupt memory.
Originally disclosed on Cisco Talos
A memory corruption vulnerability exists in the cgi.c unescape functionality of ArduPilot APWeb master branch 50b6b7ac - master branch 46177cb9. A specially-crafted HTTP request can lead to memory corruption.
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 unescape routine does not check that two characters follow a percent sign before shifting the rest of the string left, causing an out-of-bounds read and write.
Impact
A remote, unauthenticated attacker could cause memory corruption, with the vendor's CVSS rating limited to low integrity impact and no confidentiality or availability impact claimed.
What the attacker needed
Network access to the APWeb server; no authentication needed
The fix
The vendor released a patch for the unescape function that addresses the memory overwrite.
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.
A web server often has to decode text where special characters are written as a percent sign plus two hex digits, such as %41 for the letter A. This code always assumes those two extra characters are present, so if a request ends with just a percent sign it reads and writes past the end of the buffer. That kind of mistake can crash the device or corrupt its memory.
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.