Skip to content
Memory corruption Advisory Advanced CVE-2021-21901

Garrett Metal Detectors iC Module CMA check_udp_crc memcpy stack-based buffer overflow vulnerability

A stack-based buffer overflow exists in the check_udp_crc function of the Garrett iC Module CMA due to a size mismatch between the incoming UDP buffer (512 bytes) and the internal copy buffer (256 bytes). An attacker can send a crafted UDP packet to overflow the buffer and potentially execute arbitrary code.

Matt Wiseman Follow

Originally disclosed on Cisco Talos

Critical 9.8 View original

A stack-based buffer overflow vulnerability exists in the CMA checkudpcrc function of Garrett Metal Detectors’ iC Module CMA Version 5.0. A specially-crafted packet can lead to a stack-based buffer overflow during a call to memcpy.

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 check_udp_crc function allocates a 256-byte buffer but copies strlen(msg) bytes from a 512-byte source buffer without validating the length, leading to a stack-based buffer overflow.

Impact

An attacker can send a malicious UDP packet to trigger a stack-based buffer overflow, potentially leading to arbitrary code execution with high confidentiality, integrity, and availability impact.

What the attacker needed

Network access to UDP port 6877

The fix

The vulnerability was fixed by the vendor, as indicated in the timeline.

How it was found

  1. Send a UDP packet to port 6877 with a payload longer than 256 bytes.
  2. The udp_thread function receives the packet into a 512-byte buffer.
  3. The buffer is passed to check_udp_crc, which copies the payload into a 256-byte buffer using memcpy without length validation.
  4. The overflow overwrites the stack, including the program counter, leading to a crash or potential code 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.

A buffer overflow happens when a program writes more data into a fixed-size memory area than it can hold, causing adjacent memory to be overwritten. Here, the program receives a UDP packet up to 512 bytes but then copies it into a 256-byte buffer without checking the length, so a long packet can overwrite the return address and let an attacker control what code runs next.

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.