Skip to content
Memory corruption Advisory Advanced CVE-2021-21905CVE-2021-21906

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.

Matt Wiseman Follow

Originally disclosed on Cisco Talos

High 8.2 View original

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.

Matt Wiseman, on Cisco Talos

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

  1. Authenticate to the CLI on TCP port 6877.
  2. Use the setenv command to set the public_ip environment variable to a long value.
  3. 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.

More by Matt Wiseman

View all

73 more disclosed reports, best first.

More from Cisco Talos

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.