Garrett Metal Detectors iC Module CMA CLI readfile stack-based buffer overflow vulnerabilities
Two stack-based buffer overflows exist in the CMA readfile function of Garrett Metal Detectors iC Module CMA Version 5.0. An attacker who can control the contents of files read by readfile can cause stack corruption and potentially achieve remote code execution.
Originally disclosed on Cisco Talos
Two stack-based buffer overflow vulnerabilities exist in how the CMA readfile function of Garrett Metal Detectors iC Module CMA Version 5.0 is used at various locations. Convincing the system to call readfile on a specially-crafted file can lead to stack-based buffer overflows.
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 readfile function copies file contents into a caller-provided buffer without knowing its length, leading to stack-based buffer overflows when the file is larger than the buffer.
Impact
An attacker could corrupt the stack and potentially achieve remote code execution.
What the attacker needed
Authenticated CLI access; ability to set environment variables; ability to alter the secret file (for CVE-2021-21906)
The fix
The vendor patched the vulnerability.
How it was found
- Authenticate to the CLI on TCP port 6877.
- Use the setenv command to set the public_ip environment variable to a long value.
- Run the ipconfig command to trigger the overflow in get_ip.
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 buffer overflow happens when a program writes more data into a fixed-size memory area than it can hold, overwriting nearby data. Here, the readfile function copies file contents into a small buffer without checking the size, so a long file can overwrite the stack and let an attacker control the program's execution flow.
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.