CWEweakness
CWE-122 Heap-based Buffer Overflow
High
Official page ↗
- Alternate terms
- Heap Overflow, Heap Buffer Overflow
- Abstraction
- Variant
- Structure
- Simple
- Status
- Draft
- Likelihood of exploit
- High
- Languages
- C, C++, Memory-Unsafe
- CWE version
- 5.0
Description
The product writes past the end of a buffer that was allocated on the heap.
Common consequences
• Availability: DoS: Crash, Exit, or Restart, DoS: Resource Consumption (CPU), DoS: Resource Consumption (Memory) — Buffer overflows generally lead to crashes. Other attacks leading to lack of availability are possible, including putting the program into an infinite loop.
• Integrity, Confidentiality, Availability, Access Control: Execute Unauthorized Code or Commands, Bypass Protection Mechanism, Modify Memory — Buffer overflows often can be used to execute arbitrary code, which is usually outside the scope of a program's implicit security policy. Besides important user data, heap-based overflows can be used to overwrite function pointers that may be living in memory, pointing it to the attacker's code. Even in applications that do not explicitly use function pointers, the run-time will usually leave many in memory. For example, object methods in C++ are generally implemented using function pointers. Even in C programs, there is often a global offset table used by the underlying runtime.
• Integrity, Confidentiality, Availability, Access Control, Other: Execute Unauthorized Code or Commands, Bypass Protection Mechanism, Other — When the consequence is arbitrary code execution, this can often be used to subvert any other security service.
Potential mitigations
• Pre-design: Use a language or compiler that performs automatic bounds checking.
• [Architecture and Design] Use an abstraction library to abstract away risky APIs. Not a complete solution.
• [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.
• [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].
• [Implementation] Implement and perform bounds checking on input.
• [Implementation] Do not use dangerous functions such as gets. Look for their safe equivalent, which checks for the boundary.
• [Operation] Use OS-level preventative functionality. This is not a complete solution, but it provides some defense in depth.
Detection methods
• Fuzzing: Fuzz testing (fuzzing) is a powerful technique for generating large numbers of diverse inputs - either randomly or algorithmically - and dynamically invoking the code with those inputs. Even with random inputs, it is often capable of generating unexpected results such as crashes, memory corruption, or resource consumption. Fuzzing effectively produces repeatable test cases that clearly indicate bugs, which helps developers to diagnose the issues.
• 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].
Observed examples
• CVE-2025-46687: Chain: Javascript engine code does not perform a length check (CWE-1284) leading to integer overflow (CWE-190) causing allocation of smaller buffer than expected (CWE-131) resulting in a heap-based buffer overflow (CWE-122)
• CVE-2021-43537: Chain: in a web browser, an unsigned 64-bit integer is forcibly cast to a 32-bit integer (CWE-681) and potentially leading to an integer overflow (CWE-190). If an integer overflow occurs, this can cause heap memory corruption (CWE-122)
• CVE-2007-4268: Chain: integer signedness error (CWE-195) passes signed comparison, leading to heap overflow (CWE-122)
• CVE-2009-2523: Chain: product does not handle when an input string is not NULL terminated (CWE-170), leading to buffer over-read (CWE-125) or heap-based buffer overflow (CWE-122).
• 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-2010-1866: Chain: integer overflow (CWE-190) causes a negative signed value, which later bypasses a maximum-only check (CWE-839), leading to heap-based buffer overflow (CWE-122).
Related
Attack pattern · CAPEC (1)
- CAPEC-92 Forced Integer Overflow attack pattern
Observed example · CVE (6)
- CVE-2025-46687 quickjs-ng through 0.9.0 has a missing length check in JS_ReadString for a string, leading to a heap-based buffer overflow. vulnerability
- CVE-2021-43537 An incorrect type conversion of sizes from 64bit to 32bit integers allowed an attacker to corrupt memory leading to a potentially… vulnerability
- CVE-2021-29529 TensorFlow is an end-to-end open source platform for machine learning. vulnerability
- CVE-2010-1866 The dechunk filter in PHP 5.3 through 5.3.2, when decoding an HTTP chunked encoding stream, allows context-dependent attackers to cause a… vulnerability
- CVE-2009-2523 The License Logging Server (llssrv.exe) in Microsoft Windows 2000 SP4 allows remote attackers to execute arbitrary code via an RPC message… vulnerability
- CVE-2007-4268 Integer signedness error in the Networking component in Apple Mac OS X 10.4 through 10.4.10 allows local users to execute arbitrary code… vulnerability
Child of · CWE (2)
Referenced by CAPEC · weakness (1)
- CAPEC-92 Forced Integer Overflow attack pattern
Referenced by CVE · weakness (3,689)
- CVE-2026-119124 ImageMagick before 7.1.2-34 contains a heap-based buffer overflow in its -morph processing, where crafted images cause writes beyond the… vulnerability
- CVE-2026-85897 Heap-based buffer overflow in Microsoft Edge (Chromium-based) allows an unauthorized attacker to execute code over a network. vulnerability
- CVE-2026-96198 Heap-based buffer overflow in Microsoft Edge (Chromium-based) allows an unauthorized attacker to execute code over a network. vulnerability
- CVE-2026-96199 Heap-based buffer overflow in Microsoft Edge (Chromium-based) allows an unauthorized attacker to execute code over a network. vulnerability
- CVE-2026-116776 USB Test is a lightweight Windows CLI utility for verifying sector integrity and detecting overreported capacity on USB flash drives. vulnerability
- CVE-2026-118611 Alpine iLX-F511 Bluetooth OBEX Packet Handling Heap-based Buffer Overflow Remote Code Execution Vulnerability. vulnerability
- CVE-2026-47235 SimulationCraft is a tool to explore combat mechanics in World of Warcraft. vulnerability
- CVE-2026-86392 Dell PowerProtect Data Domain, Feature Release versions 7.7.1.0 through 8.8, LTS2024 release versions 7.13.1.0 through 7.13.1.80, LTS2025… vulnerability
- CVE-2026-93517 A heap buffer overflow in handling GLX RenderLarge request where dataBytes exceeds cmdlen in X.org X server before 21.1.25 and XWayland… vulnerability
- CVE-2026-93518 An integer truncation issue in XkbResizeKeyType() that could lead to a heap buffer overflow by authenticated X clients in X.org X server… vulnerability
- CVE-2026-93519 A buffer overflow when handling pointer barriers in the XFIXES extension in X.Org X server before 21.1.25 and XWayland before 24.1.14 could… vulnerability
- CVE-2026-93520 A heap buffer overflow caused by mismatching size calculations between XkbAllocNames and ChangeKeycodeRange in X.org X server before 2.1.25… vulnerability
- CVE-2026-93521 A buffer overflow in RandR ChangeProviderProperty requests in X.Org X Server before 2.1.25 and XWayland before 24.4.14 could be used by… vulnerability
- CVE-2026-93522 A heap buffer overflow caused by mismatched size usage in CopyArea CPU-to-FBO path in X.Org X Server before 21.1.15 and XWayland before… vulnerability
- CVE-2026-93523 A heap buffer overflow caused by a XIPassiveUngrabDevice request with an out-of-range modifier value in X.Org X Server before 21.1.15 and… vulnerability
- CVE-2026-93536 A use after free caused by missing lifecycle management of gesture sprites in GestureBuildSprite() in X.Org X Server before 21.1.25 and… vulnerability
- CVE-2026-108307 Tanium addressed a heap-based buffer overflow vulnerability in Index. vulnerability
- CVE-2026-109089 A buffer overflow when handling DEVICE_RESOLUTION in libXi before 1.8.4 could overflow a heap, triggered by a malicious X server. vulnerability
- CVE-2026-109090 A malicious X server could cause a heap overflow by injecting a large DEVICE_ENABLE reply when processed by libXi before 1.8.4. vulnerability
- CVE-2026-112709 A heap-based buffer overflow vulnerability in the Fireware OS authentication service allows an attacker who controls or intercepts traffic… vulnerability
- CVE-2026-112710 A heap-based buffer overflow vulnerability exists in the Fireware OS authentication service allows an attacker who controls or intercepts… vulnerability
- CVE-2026-116837 A malicious actor with access to the adjacent network could exploit a Heap-based Buffer Overflow vulnerability found in airMAX M, LTU,… vulnerability
- CVE-2026-57197 Asterisk is an open source private branch exchange and telephony toolkit. vulnerability
- CVE-2026-57198 Asterisk is an open source private branch exchange and telephony toolkit. vulnerability
- CVE-2026-76933 Heap-based Buffer Overflow Vulnerability in JP1/Automatic Job Management System 3. vulnerability
- CVE-2026-76937 Heap-based Buffer Overflow Vulnerability in JP1/Automatic Job Management System 3. vulnerability
- CVE-2026-76939 Heap-based Buffer Overflow Vulnerability in JP1/Automatic Job Management System 3. vulnerability
- CVE-2026-82120 Heap-based Buffer Overflow Vulnerability in HiRDB. vulnerability
- CVE-2026-86574 Heap-based Buffer Overflow Vulnerability in JP1/Base. vulnerability
- CVE-2026-86576 Heap-based Buffer Overflow Vulnerability in JP1 Products. vulnerability
Referenced by CWE · has member (1)
- CWE-1435 Weaknesses in the 2025 CWE Top 25 Most Dangerous Software Weaknesses view