CWE-122: Heap-based Buffer Overflow
VariantLikelihood of exploit: High
A heap overflow condition is a buffer overflow, where the buffer that can be overwritten is allocated in the heap portion of memory, generally meaning that the buffer was allocated using a routine such as malloc().
Consequences
- Availability: DoS: Crash, Exit, or Restart, DoS: Resource Consumption (CPU), DoS: Resource Consumption (Memory)
- Integrity, Confidentiality, Availability, Access Control: Execute Unauthorized Code or Commands, Bypass Protection Mechanism, Modify Memory
- Integrity, Confidentiality, Availability, Access Control, Other: Execute Unauthorized Code or Commands, Bypass Protection Mechanism, Other
How to prevent it
- 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.
Recent advisories
- GHSA-8g5g-8vmr-9782 — Pillow: Heap buffer overflow in ImagingJpegDecode
- GHSA-5x8w-8jj5-q52h — Pillow: Heap buffer overflow in FlashPix (FPX) JPEG decoding leads to code execution
- GHSA-462x-pgg6-55fp — Pillow tiled-TIFF decoder reads past tile buffer in copy4 (Unpack.c:1290)
- GHSA-332p-7hrc-92wf — Pillow: Heap buffer overflow in _tiffWriteProc when saving TIFF to BytesIO
- CVE-2026-94127 — When a BIG-IP APM access policy and an OAuth profile are configured on a virtual server, specific malicious traffic can lead to remote code execution (RCE).
- GHSA-rgj7-g3m4-5g8c — sharp: Vulnerabilities in libheif: GHSA-g89c-p67h-r497 and GHSA-2jg2-4ch7-h545
- CVE-2026-85880 — Heap-based buffer overflow in Windows ALPC allows an authorized attacker to elevate privileges locally.
- GHSA-jqhp-238x-qhgf — Microsoft Security Advisory CVE-2026-62886 – .NET Elevation of Privilege Vulnerability
- GHSA-vg44-h755-9hw7 — Microsoft Security Advisory CVE-2026-62871 – .NET Elevation of Privilege Vulnerability
- GHSA-76q6-2p6h-xjqr — ImageMagick: Heap Buffer Over-Write in X11 import with crafted window title
- CVE-2026-53362 — ipv6: account for fraggap on the paged allocation path
- GHSA-5rff-8f7c-8jmw — Open Babel has out-of-bounds write in ORCA nAtoms parser (second variant)
- GHSA-rj4c-r689-cm87 — Open Babel has out-of-bounds write in ORCA nAtoms parser
- GHSA-x2f5-4prf-w687 — Ruby json: JSON generator heap buffer overflow when streaming to an IO
- GHSA-35w3-pjm6-wj95 — Oj: Heap Buffer Overflow in Oj.dump Exception Serialization via Large Indent
MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.
Check your repos with MergeHarbor