CWEweakness
CWE-119 Improper Restriction of Operations within the Bounds of a Memory Buffer
High
Official page ↗
- Alternate terms
- Buffer Overflow, buffer overrun, memory safety
- Abstraction
- Class
- Structure
- Simple
- Status
- Stable
- Likelihood of exploit
- High
- Languages
- Assembly, C, C++, Memory-Unsafe
- CWE version
- 5.0
Description
The product performs operations on a memory buffer, but it reads from or writes to a memory location outside the buffer's intended boundary.
Common consequences
• Integrity, Confidentiality, Availability: Execute Unauthorized Code or Commands, Modify Memory — This may result in read or write operations on unexpected memory locations that could be linked to other variables, data structures, or internal program data. If the memory accessible by the attacker can be effectively controlled, it may be possible to execute arbitrary code, as with a standard buffer overflow. If the attacker can overwrite a pointer's worth of memory (usually 32 or 64 bits), they can alter the intended control flow by redirecting a function pointer to their own malicious code. Even when the attacker can only modify a single byte, arbitrary code execution can be possible. Sometimes this is because the same problem can be exploited repeatedly to the same effect. Other times it is because the attacker can overwrite security-critical application-specific data -- such as a flag indicating whether the user is an administrator.
• Availability, Confidentiality: Read Memory, DoS: Crash, Exit, or Restart, DoS: Resource Consumption (CPU), DoS: Resource Consumption (Memory) — Out of bounds memory access will very likely result in the corruption of relevant memory, and perhaps instructions, possibly leading to a crash. Other attacks leading to lack of availability are possible, including putting the program into an infinite loop.
• Confidentiality: Read Memory — In the case of an out-of-bounds read, the attacker may have access to sensitive information. If the sensitive information contains system details, such as the current buffer's position in memory, this knowledge can be used to craft further attacks, possibly with more severe consequences.
Potential mitigations
• [Requirements] Use a language that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid.
For example, many languages that perform their own memory management, such as Java and Perl, are not subject to buffer overflows. Other languages, such as Ada and C#, typically provide overflow protection, but the protection can be disabled by the programmer.
Be wary that a language's interface to native code may still be subject to overflows, even if the language itself is theoretically safe.
• [Architecture and Design] Use a vetted library or framework that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid.
Examples include the Safe C String Library (SafeStr) by Messier and Viega [REF-57], and the Strsafe.h library from Microsoft [REF-56]. These libraries provide safer versions of overflow-prone string-handling functions.
• [Operation, Build and Compilation] Use automatic buffer overflow detection mechanisms that are offered by certain compilers or compiler extensions. Examples include: the Microsoft Visual Studio /GS flag, Fedora/Red Hat FORTIFY_SOURCE GCC flag, StackGuard, and ProPolice, which provide various mechanisms including canary-based detection and range/index checking.
D3-SFCV (Stack Frame Canary Validation) from D3FEND [REF-1334] discusses canary-based detection in detail.
• [Implementation] Consider adhering to the following rules when allocating and managing an application's memory:
• Double check that the buffer is as large as specified.
• When using functions that accept a number of bytes to copy, such as strncpy(), be aware that if the destination buffer size is equal to the source buffer size, it may not NULL-terminate the string.
• Check buffer boundaries if accessing the buffer in a loop and make sure there is no danger of writing past the allocated space.
• If necessary, truncate all input strings to a reasonable length before passing them to the copy and concatenation functions.
• [Operation, Build and Compilation] Run or compile the software using features or extensions that randomly arrange the positions of a program's executable and libraries in memory. Because this makes the addresses unpredictable, it can prevent an attacker from reliably jumping to exploitable code.
Examples include Address Space Layout Randomization (ASLR) [REF-58] [REF-60] and Position-Independent Executables (PIE) [REF-64]. Imported modules may be similarly realigned if their default memory addresses conflict with other modules, in a process known as "rebasing" (for Windows) and "prelinking" (for Linux) [REF-1332] using randomly generated addresses. ASLR for libraries cannot be used in conjunction with prelink since it would require relocating the libraries at run-time, defeating the whole purpose of prelinking.
For more information on these techniques see D3-SAOR (Segment Address Offset Randomization) from D3FEND [REF-1335].
• [Operation] Use a CPU and operating system that offers Data Execution Protection (using hardware NX or XD bits) or the equivalent techniques that simulate this feature in software, such as PaX [REF-60] [REF-61]. These techniques ensure that any instruction executed is exclusively at a memory address that is part of the code segment.
For more information on these techniques see D3-PSEP (Process Segment Execution Prevention) from D3FEND [REF-1336].
• [Implementation] Replace unbounded copy functions with analogous functions that support length arguments, such as strcpy with strncpy. Create these if they are not available.
Detection methods
• Automated Static Analysis: This weakness can often be detected using automated static analysis tools. Many modern tools use data flow analysis or constraint-based techniques to minimize the number of false positives.
Automated static analysis generally does not account for environmental considerations when reporting out-of-bounds memory operations. This can make it difficult for users to determine which warnings should be investigated first. For example, an analysis tool might report buffer overflows that originate from command line arguments in a program that is not expected to run with setuid or other special privileges.
• Automated Dynamic Analysis: This weakness can be detected using dynamic tools and techniques that interact with the software using large test suites with many diverse inputs, such as fuzz testing (fuzzing), robustness testing, and fault injection. The software's operation may slow down, but it should not become unstable, crash, or generate incorrect results.
• Automated Dynamic Analysis: Use tools that are integrated during
compilation to insert runtime error-checking mechanisms
related to memory safety errors, such as AddressSanitizer
(ASan) for C/C++ [REF-1518].
• Automated Static Analysis - Binary or Bytecode: According to SOAR [REF-1479], the following detection techniques may be useful:
Cost effective for partial coverage:
• Binary / Bytecode Quality Analysis
• Bytecode Weakness Analysis - including disassembler + source code weakness analysis
• Binary Weakness Analysis - including disassembler + source code weakness analysis
• Manual Static Analysis - Binary or Bytecode: According to SOAR [REF-1479], the following detection techniques may be useful:
Cost effective for partial coverage:
• Binary / Bytecode disassembler - then use manual analysis for vulnerabilities & anomalies
• Dynamic Analysis with Automated Results Interpretation: According to SOAR [REF-1479], the following detection techniques may be useful:
Cost effective for partial coverage:
• Web Application Scanner
• Web Services Scanner
• Database Scanners
• Dynamic Analysis with Manual Results Interpretation: According to SOAR [REF-1479], the following detection techniques may be useful:
Cost effective for partial coverage:
• Fuzz Tester
• Framework-based Fuzzer
• Manual Static Analysis - Source Code: According to SOAR [REF-1479], the following detection techniques may be useful:
Cost effective for partial coverage:
• Focused Manual Spotcheck - Focused manual analysis of source
• Manual Source Code Review (not inspections)
• Automated Static Analysis - Source Code: According to SOAR [REF-1479], the following detection techniques may be useful:
Highly cost effective:
• Source code Weakness Analyzer
• Context-configured Source Code Weakness Analyzer
Cost effective for partial coverage:
• Source Code Quality Analyzer
• Architecture or Design Review: According to SOAR [REF-1479], the following detection techniques may be useful:
Highly cost effective:
• Formal Methods / Correct-By-Construction
Cost effective for partial coverage:
• Inspection (IEEE 1028 standard) (can apply to requirements, design, source code, etc.)
Observed examples
• CVE-2021-22991: Incorrect URI normalization in application traffic product leads to buffer overflow, as exploited in the wild per CISA KEV.
• CVE-2025-47153: Chain: build process for JavaScript runtime environment can have inconsistent sizes for off_t (CWE-1102), allowing out-of-bounds access / segmentation fault (CWE-119)
• CVE-2020-29557: Buffer overflow in Wi-Fi router web interface, as exploited in the wild per CISA KEV.
• CVE-2009-2550: Classic stack-based buffer overflow in media player using a long entry in a playlist
• CVE-2009-2403: Heap-based buffer overflow in media player using a long entry in a playlist
• CVE-2009-0689: large precision value in a format string triggers overflow
• CVE-2009-0690: negative offset value leads to out-of-bounds read
• CVE-2009-1532: malformed inputs cause accesses of uninitialized or previously-deleted objects, leading to memory corruption
• CVE-2009-1528: Chain: lack of synchronization leads to memory corruption
• CVE-2021-29529: Chain: machine-learning product can have a heap-based
buffer overflow (CWE-122) when some integer-oriented bounds are
calculated by using ceiling() and floor() on floating point values
(CWE-1339)
• CVE-2009-0558: attacker-controlled array index leads to code execution
• CVE-2009-0269: Chain: -1 value from a function call was intended to indicate an error, but is used as an array index instead.
• CVE-2009-0566: Chain: incorrect calculations lead to incorrect pointer dereference and memory corruption
• CVE-2009-1350: product accepts crafted messages that lead to a dereference of an arbitrary pointer
• CVE-2009-0191: Chain: malformed input causes dereference of uninitialized memory
• CVE-2008-4113: OS kernel trusts userland-supplied length value, allowing reading of sensitive information
• CVE-2005-1513: Chain: integer overflow in securely-coded mail program leads to buffer overflow. In 2005, this was regarded as unrealistic to exploit, but in 2020, it was rediscovered to be easier to exploit due to evolutions of the technology.
• CVE-2003-0542: buffer overflow involving a regular expression with a large number of captures
• CVE-2017-1000121: Chain: unchecked message size metadata allows integer overflow (CWE-190) leading to buffer overflow (CWE-119).
Related
Attack pattern · CAPEC (12)
- CAPEC-10 Buffer Overflow via Environment Variables attack pattern
- CAPEC-100 Overflow Buffers attack pattern
- CAPEC-123 Buffer Manipulation attack pattern
- CAPEC-14 Client-side Injection-induced Buffer Overflow attack pattern
- CAPEC-24 Filter Failure through Buffer Overflow attack pattern
- CAPEC-42 MIME Conversion attack pattern
- CAPEC-44 Overflow Binary Resource File attack pattern
- CAPEC-45 Buffer Overflow via Symbolic Links attack pattern
- CAPEC-46 Overflow Variables and Tags attack pattern
- CAPEC-47 Buffer Overflow via Parameter Expansion attack pattern
- CAPEC-8 Buffer Overflow in an API Call attack pattern
- CAPEC-9 Buffer Overflow in Local Command-Line Utilities attack pattern
Observed example · CVE (19)
- CVE-2025-47153 Certain build processes for libuv and Node.js for 32-bit systems, such as for the nodejs binary package through… vulnerability
- CVE-2021-29529 TensorFlow is an end-to-end open source platform for machine learning. vulnerability
- CVE-2021-22991 On BIG-IP versions 16.0.x before 16.0.1.1, 15.1.x before 15.1.2.1, 14.1.x before 14.1.4, 13.1.x before 13.1.3.6, and 12.1.x before… vulnerability
- CVE-2020-29557 An issue was discovered on D-Link DIR-825 R1 devices through 3.0.1 before 2020-11-20. vulnerability
- CVE-2017-1000121 The UNIX IPC layer in WebKit, including WebKitGTK+ prior to 2.16.3, does not properly validate message size metadata, allowing a… vulnerability
- CVE-2009-2550 Stack-based buffer overflow in Hamster Audio Player 0.3a allows remote attackers to execute arbitrary code via a long string in a (1) .m3u… vulnerability
- CVE-2009-0566 Microsoft Office Publisher 2007 SP1 does not properly calculate object handler data for Publisher files, which allows remote attackers to… vulnerability
- CVE-2009-2403 Heap-based buffer overflow in SCMPX 1.5.1 allows remote attackers to cause a denial of service (application crash) or execute arbitrary… vulnerability
- CVE-2009-0689 Array index error in the (1) dtoa implementation in dtoa.c (aka pdtoa.c) and the (2) gdtoa (aka new dtoa) implementation in gdtoa/misc.c in… vulnerability
- CVE-2009-0690 The Foxit JPEG2000/JBIG2 Decoder add-on before 2.0.2009.616 for Foxit Reader 3.0 before Build 1817 does not properly handle a negative… vulnerability
- CVE-2009-0558 Array index error in Excel in Microsoft Office 2000 SP3 and Office 2004 and 2008 for Mac, and Open XML File Format Converter for Mac,… vulnerability
- CVE-2009-1528 Microsoft Internet Explorer 6 and 7 for Windows XP SP2 and SP3; 6 and 7 for Server 2003 SP2; 7 for Vista Gold, SP1, and SP2; and 7 for… vulnerability
- CVE-2009-1532 Microsoft Internet Explorer 8 for Windows XP SP2 and SP3; 8 for Server 2003 SP2; 8 for Vista Gold, SP1, and SP2; and 8 for Server 2008 SP2… vulnerability
- CVE-2009-1350 Unspecified vulnerability in xtagent.exe in Novell NetIdentity Client before 1.2.4 allows remote attackers to execute arbitrary code by… vulnerability
- CVE-2009-0191 Foxit Reader 2.3 before Build 3902 and 3.0 before Build 1506, including 3.0.2009.1301, does not properly handle a JBIG2 symbol dictionary… vulnerability
- CVE-2009-0269 fs/ecryptfs/inode.c in the eCryptfs subsystem in the Linux kernel before 2.6.28.1 allows local users to cause a denial of service (fault or… vulnerability
- CVE-2008-4113 The sctp_getsockopt_hmac_ident function in net/sctp/socket.c in the Stream Control Transmission Protocol (sctp) implementation in the Linux… vulnerability
- CVE-2005-1513 Integer overflow in the stralloc_readyplus function in qmail, when running on 64 bit platforms with a large amount of virtual memory,… vulnerability
- CVE-2003-0542 Multiple stack-based buffer overflows in (1) mod_alias and (2) mod_rewrite for Apache before 1.3.29 allow attackers to create configuration… vulnerability
Child of · CWE (2)
Referenced by CAPEC · weakness (12)
- CAPEC-10 Buffer Overflow via Environment Variables attack pattern
- CAPEC-100 Overflow Buffers attack pattern
- CAPEC-123 Buffer Manipulation attack pattern
- CAPEC-14 Client-side Injection-induced Buffer Overflow attack pattern
- CAPEC-24 Filter Failure through Buffer Overflow attack pattern
- CAPEC-42 MIME Conversion attack pattern
- CAPEC-44 Overflow Binary Resource File attack pattern
- CAPEC-45 Buffer Overflow via Symbolic Links attack pattern
- CAPEC-46 Overflow Variables and Tags attack pattern
- CAPEC-47 Buffer Overflow via Parameter Expansion attack pattern
- CAPEC-8 Buffer Overflow in an API Call attack pattern
- CAPEC-9 Buffer Overflow in Local Command-Line Utilities attack pattern
Referenced by CVE · weakness (14,649)
- CVE-2026-116620 A security vulnerability has been detected in Tencent RapidJSON up to 1.1.0. vulnerability
- CVE-2026-118305 Memory corruption in Turbolev in Google Chrome prior to 156.0.8078.73 allowed a remote attacker to potentially execute arbitrary code… vulnerability
- CVE-2026-118306 Memory corruption in FileSystem in Google Chrome prior to 156.0.8078.73 allowed a remote attacker to potentially execute arbitrary code… vulnerability
- CVE-2026-118311 Memory corruption in Media in Google Chrome prior to 156.0.8078.73 allowed a remote attacker to potentially execute arbitrary code inside… vulnerability
- CVE-2026-118312 Memory corruption in Paint in Google Chrome prior to 156.0.8078.73 allowed a remote attacker to potentially execute arbitrary code outside… vulnerability
- CVE-2026-118317 Memory corruption in HTML in Google Chrome prior to 156.0.8078.73 allowed a remote attacker to potentially execute arbitrary code inside… vulnerability
- CVE-2026-118319 Memory corruption in Skia in Google Chrome prior to 156.0.8078.73 allowed a remote attacker to potentially read memory inside the sandbox… vulnerability
- CVE-2026-118320 Memory corruption in V8 in Google Chrome prior to 156.0.8078.73 allowed a remote attacker to potentially execute arbitrary code inside the… vulnerability
- CVE-2026-118322 Memory corruption in ANGLE in Google Chrome prior to 156.0.8078.73 allowed a remote attacker to potentially read memory inside the sandbox… vulnerability
- CVE-2026-118327 Memory corruption in Media in Google Chrome prior to 156.0.8078.73 allowed a remote attacker to potentially execute arbitrary code inside… vulnerability
- CVE-2026-118340 Memory corruption in Skia in Google Chrome prior to 156.0.8078.73 allowed a remote attacker to potentially execute arbitrary code outside… vulnerability
- CVE-2026-118349 Memory corruption in Payments in Google Chrome prior to 156.0.8078.73 allowed a remote attacker to execute arbitrary code inside the… vulnerability
- CVE-2026-118351 Memory corruption in Skia in Google Chrome prior to 156.0.8078.73 allowed a remote attacker to execute arbitrary code inside the sandbox… vulnerability
- CVE-2026-118352 Memory corruption in Cache in Google Chrome prior to 156.0.8078.73 allowed a remote attacker to potentially execute arbitrary code inside… vulnerability
- CVE-2026-118358 Memory corruption in WebAudio in Google Chrome prior to 156.0.8078.73 allowed a remote attacker to potentially execute arbitrary code… vulnerability
- CVE-2026-118359 Memory corruption in V8 in Google Chrome prior to 156.0.8078.73 allowed a remote attacker to potentially execute arbitrary code inside the… vulnerability
- CVE-2026-112471 A buffer overflow was addressed with improved bounds checking. vulnerability
- CVE-2026-112688 A memory corruption issue was addressed with improved memory handling. vulnerability
- CVE-2026-113907 A buffer overflow issue was addressed with improved memory handling. vulnerability
- CVE-2026-116099 A flaw has been found in Fusion Creators Studio SCP Containment Breach Multiplayer up to 1.295. vulnerability
- CVE-2026-116124 A security vulnerability has been detected in GNOME libgsf up to 1.14.60. vulnerability
- CVE-2026-116258 A vulnerability was identified in libimobiledevice up to 1.4.0. vulnerability
- CVE-2026-116259 A security flaw has been discovered in libimobiledevice up to 1.4.0. vulnerability
- CVE-2026-116260 A weakness has been identified in libimobiledevice up to 1.4.0. vulnerability
- CVE-2026-116261 A security vulnerability has been detected in libimobiledevice up to 1.4.0. vulnerability
- CVE-2026-116262 A vulnerability was detected in libimobiledevice up to 1.4.0. vulnerability
- CVE-2026-116463 A vulnerability was identified in FastStone Image Viewer up to 8.5. vulnerability
- CVE-2026-116502 A flaw has been found in turboderp-org ExLlamaV2 up to 0.3.2. vulnerability
- CVE-2026-116508 A security flaw has been discovered in TOTOLINK A950RG 4.1.2cu.5268_B20221104. vulnerability
- CVE-2026-116096 A weakness has been identified in ggml-org llama.cpp. vulnerability
Referenced by CWE · can precede (12)
- CWE-1257 Improper Access Control Applied to Mirrored or Aliased Memory Regions weakness
- CWE-1260 Improper Handling of Overlap Between Protected Memory Ranges weakness
- CWE-128 Wrap-around Error weakness
- CWE-129 Improper Validation of Array Index weakness
- CWE-131 Incorrect Calculation of Buffer Size weakness
- CWE-1339 Insufficient Precision or Accuracy of a Real Number weakness
- CWE-190 Integer Overflow or Wraparound weakness
- CWE-193 Off-by-one Error weakness
- CWE-195 Signed to Unsigned Conversion Error weakness
- CWE-20 Improper Input Validation weakness
- CWE-839 Numeric Range Comparison Without Minimum Check weakness
- CWE-843 Access of Resource Using Incompatible Type weakness
Referenced by CWE · child of (13)
- CWE-120 Buffer Copy without Checking Size of Input weakness
- CWE-123 Write-what-where Condition weakness
- CWE-125 Out-of-bounds Read weakness
- CWE-130 Improper Handling of Length Parameter Inconsistency weakness
- CWE-466 Return of Pointer Value Outside of Expected Range weakness
- CWE-786 Access of Memory Location Before Start of Buffer weakness
- CWE-787 Out-of-bounds Write weakness
- CWE-788 Access of Memory Location After End of Buffer weakness
- CWE-805 Buffer Access with Incorrect Length Value weakness
- CWE-822 Untrusted Pointer Dereference weakness
- CWE-823 Use of Out-of-range Pointer Offset weakness
- CWE-824 Access of Uninitialized Pointer weakness
- CWE-825 Expired Pointer Dereference weakness
Referenced by CWE · has member (9)
- CWE-1003 Weaknesses for Simplified Mapping of Published Vulnerabilities view
- CWE-1200 Weaknesses in the 2019 CWE Top 25 Most Dangerous Software Errors view
- CWE-1337 Weaknesses in the 2021 CWE Top 25 Most Dangerous Software Weaknesses view
- CWE-1340 CISQ Data Protection Measures view
- CWE-1350 Weaknesses in the 2020 CWE Top 25 Most Dangerous Software Weaknesses view
- CWE-1387 Weaknesses in the 2022 CWE Top 25 Most Dangerous Software Weaknesses view
- CWE-1425 Weaknesses in the 2023 CWE Top 25 Most Dangerous Software Weaknesses view
- CWE-1430 Weaknesses in the 2024 CWE Top 25 Most Dangerous Software Weaknesses view
- CWE-635 Weaknesses Originally Used by NVD from 2008 to 2016 view