Join our Newsletter — 33% off our NHI Course
Threats, Abuse & Incident Response

CWE-120

← Back to Glossary
By NHI Mgmt Group Updated November 18, 2026 Domain: Threats, Abuse & Incident Response

CWE-120 is a weakness class for classic buffer overflow in which data written past the end of a fixed-size buffer corrupts adjacent memory. It usually arises in languages or code paths without automatic bounds checking, and can lead to crashes, memory corruption or code execution if an attacker controls the input.

What CWE-120 actually describes

CWE-120 is a classic buffer overflow weakness, meaning code writes past the end of a fixed-size buffer and corrupts adjacent memory. The core issue is not just “bad input”, but the absence of effective bounds enforcement at the point where data is copied, appended, or formatted. In practice, that can destabilise a program or create a path to controlled code execution.

This weakness is most dangerous where the program handles attacker-influenced data in low-level languages, unsafe APIs, or hand-written memory management. A buffer overflow is therefore both a correctness failure and a security failure: once memory layout is disturbed, the outcome can range from a simple crash to corrupted control data.

Why buffer overflows become security issues

The security impact comes from what sits next to the buffer in memory. If the overwrite reaches return addresses, function pointers, vtables, length fields, or other control structures, an attacker may steer program execution or change security-relevant state. Even when execution is not achieved, memory corruption can still break integrity, availability, and trust in the process.

Classic overflows are often associated with patterns such as unchecked copy operations, incorrect length calculations, off-by-one mistakes, and assumptions that input will always fit the destination buffer. Those failures are especially severe because they can be triggered before authentication, during parsing, or in privileged components that process untrusted data.

For a broader weakness taxonomy and adjacent memory-safety patterns, the CWE Top 25 Guide is a useful companion reference, especially where buffer overflow sits alongside other high-impact software weaknesses.

How organisations assess exposure

Exposure assessment starts with finding where the weakness could exist: older C or C++ code, embedded software, parsers, protocol handlers, image or file decoders, and any code path that copies variable-length data into fixed buffers. Asset inventory matters because the same weakness may exist in a library, appliance, SDK, or legacy service that is easy to overlook.

Organisations also need to know whether the vulnerable code is internet-facing, reachable through a partner integration, or callable only from a trusted internal path. A buffer overflow in a local utility is serious; the same weakness in a remotely reachable service is usually much more urgent because it expands the exploit path and the blast radius.

When a weakness maps into broader vulnerability management workflows, a governance view of CWE, CVE and platform mapping helps teams connect root cause to affected products and remediations. The CVE, CWE and CPE Guide is useful for understanding how a weakness class is tracked differently from a product vulnerability.

Remediation and compensating controls

The durable fix is to remove the unsafe memory access pattern, not to rely on input “cleanliness” alone. Safe bounds checking, safer libraries, correct size handling, compiler hardening, and eliminating unnecessary manual buffer management all reduce exposure. In mature codebases, remediation often includes code review of all adjacent parsing and copy logic, not only the function that overflowed.

When a patch or source change cannot be applied immediately, compensating controls should reduce exploitability. Typical measures include restricting attack surface, placing exposed services behind additional filtering, reducing privileges of the process, and limiting which inputs can reach the vulnerable path. These controls do not fix the weakness, but they can make exploitation harder and reduce the damage if an exploit is attempted.

Detection, validation and post-patch review

Detection is difficult because successful exploitation may look like a crash, a hang, or apparently random corruption until the final stage of compromise. Defensive teams should treat repeated faults in the same code path, unusual process termination, or memory corruption alerts as signals to investigate for exploit attempts rather than isolated stability issues.

After remediation, organisations should still review the affected system for signs that the overflow was already used as an entry point. That means checking logs, crash artefacts, surrounding processes, and any credentials or tokens the process could access. If the vulnerable component had elevated trust, post-patch review should also confirm that no additional privilege abuse or persistence was established before the fix.

Because the weakness class is so foundational to software hardening, the NIST SP 800-53 Rev 5 Security and Privacy Controls is relevant where organisations need to pair secure coding, boundary checks, and monitoring with broader control expectations.

Risk and Threat Considerations

Buffer overflows are a high-value target because they can turn a simple input handling flaw into memory corruption, denial of service, or code execution. The risk is greatest when the vulnerable component is exposed to untrusted input and runs with meaningful privilege or access to sensitive data.

Failure mechanism: The attacker supplies input that exceeds the fixed buffer, overwrites neighbouring memory, and then abuses the corrupted state to alter execution flow or destabilise the process.

Impact: Successful exploitation can cause crashes, data corruption, privilege abuse, service interruption, or full compromise of the affected application or host.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

NIST SP 800-53 Rev 5, NIST CSF 2.0 and OWASP ASVS set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
NIST SP 800-53 Rev 5SI-10 — Information Input ValidationBuffer overflow prevention depends on validating input sizes before writes.
SI-7 — Software, Firmware, and Information IntegrityOverflow exploitation can corrupt program integrity and justify integrity checks after remediation.
CM-7 — Least FunctionalityReducing exposed features and parsing paths lowers the chance of reachable overflow conditions.
Recommendation — Validate all external input sizes before copying data into fixed buffers. Monitor for corruption indicators and verify software integrity after suspected exploitation. Disable unnecessary code paths and services that expose memory-unsafe parsing.
NIST CSF 2.0PR.DS-01 — Data-at-rest is protectedMemory corruption can expose sensitive data handled by the affected component.
Recommendation — Protect sensitive data handled by vulnerable components and limit what they can access.
OWASP ASVSV15 — Secure Coding and ArchitectureASVS secure coding expectations directly cover memory-safe design and dangerous buffer handling.
Recommendation — Apply secure coding requirements that eliminate unsafe buffer handling and length errors.

Practitioner Guidance

What to watch for: Treat every fixed-size buffer, unsafe copy routine, and manual length calculation as a review point, especially in parsers, network services, and legacy code. The practical question is whether the code can ever receive attacker-controlled data larger than the destination without a hard bounds check.

Practitioner takeaway: If a code path cannot prove safe bounds at every write, it should be redesigned, not merely tested more heavily.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Reviewed and updated by the NHIMG editorial team on November 18, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org