CWE-120

A buffer overflow occurs when data is written beyond the boundaries of allocated memory. In compiled binaries, this can be exploited to execute arbitrary code o...

Verified by Precogs Threat Research
BASE SCORE
7.5 CRITICAL

Precogs AI Insight

"Precogs AI Binary SAST detects buffer overflow patterns in compiled code through AI-powered control flow analysis, flagging unsafe memory operations even without source code access."

EXPLOIT PROBABILITYHigh
PUBLIC POCAvailable

What is CWE-120 (Buffer Copy without Checking Size of Input (Buffer Overflow))?

A buffer overflow occurs when data is written beyond the boundaries of allocated memory. In compiled binaries, this can be exploited to execute arbitrary code or crash the system. Common in firmware and embedded systems written in C/C++.

Vulnerability Insights

In the context of binary ai-powered sast vulnerabilities, this vulnerability poses significant risk because compiled binaries and complex AI logic cannot be easily patched without vendor cooperation. Organizations relying on third-party software must use structural analysis tools to detect these flaws.

Impact on Systems

  • Denial of Service: Application crash due to corrupted memory
  • Arbitrary Code Execution: Leveraging overwritten instruction pointers
  • Data Manipulation: Altering adjacent variables in memory

Real-World Attack Scenario

By supplying input larger than the allocated 10 bytes, an attacker triggers a classic buffer overflow. The excess data spills into adjacent memory spaces, corrupting execution flow or altering critical variables, allowing them to force the application to execute arbitrary payloads or crash reliably.

Code Examples

Vulnerable Implementation

char dst[10];
// VULNERABLE: No checking on the source length before copying
strcpy(dst, src);

Secure Alternative

char dst[10];
// SECURE: Use safer alternatives with strict length limitations
snprintf(dst, sizeof(dst), "%s", src);

Remediation

Ensure robust input validation, boundary checking, and adherence to secure architecture frameworks when designing Binary SAST solutions. Use automated code scanning or binary analysis to detect flaws early in the SDLC.