Weakness · High
CWE-787: Out-of-bounds Write
What it is
The product writes data past the end, or before the beginning, of the intended buffer.
- Severity (our rating)
- High
- Likelihood of exploit
- High
- Introduced during
- Implementation
- Exploited in the wild
- 105 known exploited CVEs
What an attacker can do
- Modify Memory (Integrity)
- Execute Unauthorized Code or Commands (Integrity)
- DoS: Crash, Exit, or Restart (Availability)
- Unexpected State (Other)
How to prevent it
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, and the Strsafe.h library from Microsoft. These libraries provide safer versions of overflow-prone string-handling functions.
Operation
- 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 discusses canary-based detection in detail.
- 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) and Position-Independent Executables (PIE). 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) 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.
- 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. 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.
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.
- Replace unbounded copy functions with analogous functions that support length arguments, such as strcpy with strncpy. Create these if they are not available.
How to find it
- 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++.
Exploited in the wild: 105 CVEs
Vulnerabilities caused by CWE-787 that attackers have used, from CISA's Known Exploited Vulnerabilities catalog, newest first.
- CVE-2026-86950Apple Multiple Products Out-of-Bounds Write Vulnerability · added September 29, 2026
- CVE-2026-53266Linux Kernel Out-of-Bounds Write Vulnerability · added September 18, 2026
- CVE-2026-87491Google Chromium V8 Out of Bounds Write Vulnerability · added September 9, 2026
- CVE-2025-25249Fortinet Multiple Products Heap-based Buffer Overflow Vulnerability · added September 9, 2026
- CVE-2022-0995Linux Kernel Out-of-Bounds Write Vulnerability · added August 26, 2026
- CVE-2026-11645Google Chromium V8 Out-of-Bounds Read and Write Vulnerability · added June 9, 2026
- CVE-2026-0300Palo Alto Networks PAN-OS Out-of-bounds Write Vulnerability · added May 6, 2026
- CVE-2026-3909Google Skia Out-of-Bounds Write Vulnerability · added March 13, 2026
- CVE-2024-37079Broadcom VMware vCenter Server Out-of-bounds Write Vulnerability · added January 23, 2026
- CVE-2025-14733 ransomwareWatchGuard Firebox Out of Bounds Write Vulnerability · added December 19, 2025
- CVE-2025-9242WatchGuard Firebox Out-of-Bounds Write Vulnerability · added November 12, 2025
- CVE-2025-21042Samsung Mobile Devices Out-of-Bounds Write Vulnerability · added November 10, 2025
- CVE-2021-22555Linux Kernel Heap Out-of-Bounds Write Vulnerability · added October 6, 2025
- CVE-2025-21043Samsung Mobile Devices Out-of-Bounds Write Vulnerability · added October 2, 2025
- CVE-2025-43300Apple iOS, iPadOS, and macOS Out-of-Bounds Write Vulnerability · added August 21, 2025
- CVE-2025-5419Google Chromium V8 Out-of-Bounds Read and Write Vulnerability · added June 5, 2025
- CVE-2025-27363FreeType Out-of-Bounds Write Vulnerability · added May 6, 2025
- CVE-2024-53197Linux Kernel Out-of-Bounds Access Vulnerability · added April 9, 2025
- CVE-2025-24201Apple Multiple Products WebKit Out-of-Bounds Write Vulnerability · added March 13, 2025
- CVE-2024-53104Linux Kernel Out-of-Bounds Write Vulnerability · added February 5, 2025
- CVE-2024-4761Google Chromium V8 Out-of-Bounds Memory Write Vulnerability · added May 16, 2024
- CVE-2024-23296Apple Multiple Products Memory Corruption Vulnerability · added March 6, 2024
- CVE-2024-23225Apple Multiple Products Memory Corruption Vulnerability · added March 6, 2024
- CVE-2024-21762 ransomwareFortinet FortiOS Out-of-Bound Write Vulnerability · added February 9, 2024
- CVE-2023-34048VMware vCenter Server Out-of-Bounds Write Vulnerability · added January 22, 2024
- CVE-2024-0519Google Chromium V8 Out-of-Bounds Memory Access Vulnerability · added January 17, 2024
- CVE-2023-7024Google Chromium WebRTC Heap Buffer Overflow Vulnerability · added January 2, 2024
- CVE-2023-42917Apple Multiple Products WebKit Memory Corruption Vulnerability · added December 4, 2023
- CVE-2023-20109Cisco IOS and IOS XE Group Encrypted Transport VPN Out-of-Bounds Write Vulnerability · added October 10, 2023
- CVE-2023-5217Google Chromium libvpx Heap Buffer Overflow Vulnerability · added October 2, 2023
- CVE-2023-26369Adobe Acrobat and Reader Out-of-Bounds Write Vulnerability · added September 14, 2023
- CVE-2023-4863Google Chromium WebP Heap-Based Buffer Overflow Vulnerability · added September 13, 2023
- CVE-2021-25372Samsung Mobile Devices Improper Boundary Check Vulnerability · added June 29, 2023
- CVE-2023-32435Apple Multiple Products WebKit Memory Corruption Vulnerability · added June 23, 2023
- CVE-2023-28206Apple iOS, iPadOS, and macOS IOSurfaceAccelerator Out-of-Bounds Write Vulnerability · added April 10, 2023
- CVE-2021-30900Apple iOS, iPadOS, and macOS Out-of-Bounds Write Vulnerability · added March 30, 2023
- CVE-2022-4135Google Chromium GPU Heap Buffer Overflow Vulnerability · added November 28, 2022
- CVE-2022-41128Microsoft Windows Scripting Languages Remote Code Execution Vulnerability · added November 8, 2022
- CVE-2022-41125Microsoft Windows CNG Key Isolation Service Privilege Escalation Vulnerability · added November 8, 2022
- CVE-2022-41073 ransomwareMicrosoft Windows Print Spooler Privilege Escalation Vulnerability · added November 8, 2022
- CVE-2022-42827Apple iOS and iPadOS Out-of-Bounds Write Vulnerability · added October 25, 2022
- CVE-2022-37969 ransomwareMicrosoft Windows Common Log File System (CLFS) Driver Privilege Escalation Vulnerability · added September 14, 2022
- CVE-2022-32917Apple iOS, iPadOS, and macOS Remote Code Execution Vulnerability · added September 14, 2022
- CVE-2021-38406Delta Electronics DOPSoft 2 Improper Input Validation Vulnerability · added August 25, 2022
- CVE-2022-32894Apple iOS and macOS Out-of-Bounds Write Vulnerability · added August 18, 2022
- CVE-2022-32893Apple iOS and macOS Out-of-Bounds Write Vulnerability · added August 18, 2022
- CVE-2021-4034 ransomwareRed Hat Polkit Out-of-Bounds Read and Write Vulnerability · added June 27, 2022
- CVE-2020-9907Apple Multiple Products Memory Corruption Vulnerability · added June 27, 2022
- CVE-2020-3837Apple Multiple Products Memory Corruption Vulnerability · added June 27, 2022
- CVE-2019-5825Google Chromium V8 Out-of-Bounds Write Vulnerability · added June 8, 2022
- CVE-2018-17480Google Chromium V8 Out-of-Bounds Write Vulnerability · added June 8, 2022
- CVE-2018-6065Google Chromium V8 Integer Overflow Vulnerability · added June 8, 2022
- CVE-2016-5198Google Chromium V8 Out-of-Bounds Memory Vulnerability · added June 8, 2022
- CVE-2012-0754Adobe Flash Player Memory Corruption Vulnerability · added June 8, 2022
- CVE-2011-2462Adobe Reader and Acrobat Universal 3D Memory Corruption Vulnerability · added June 8, 2022
- CVE-2010-1297Adobe Flash Player Memory Corruption Vulnerability · added June 8, 2022
- CVE-2021-30883Apple Multiple Products Memory Corruption Vulnerability · added May 23, 2022
- CVE-2020-1027Microsoft Windows Kernel Privilege Escalation Vulnerability · added May 23, 2022
- CVE-2019-7287Apple iOS Memory Corruption Vulnerability · added May 23, 2022
- CVE-2019-7286Apple Multiple Products Memory Corruption Vulnerability · added May 23, 2022
- CVE-2018-5002Adobe Flash Player Stack-based Buffer Overflow Vulnerability · added May 23, 2022
- CVE-2022-24521 ransomwareMicrosoft Windows CLFS Driver Privilege Escalation Vulnerability · added April 13, 2022
- CVE-2021-39793Google Pixel Out-of-Bounds Write Vulnerability · added April 11, 2022
- CVE-2018-8373Microsoft Scripting Engine Memory Corruption Vulnerability · added March 25, 2022
- CVE-2019-16928Exim Out-of-bounds Write Vulnerability · added March 3, 2022
- CVE-2015-3043Adobe Flash Player Memory Corruption Vulnerability · added March 3, 2022
- CVE-2013-0640Adobe Reader and Acrobat Memory Corruption Vulnerability · added March 3, 2022
- CVE-2018-8174 ransomwareMicrosoft Windows VBScript Engine Out-of-Bounds Write Vulnerability · added February 15, 2022
- CVE-2022-21882 ransomwareMicrosoft Win32k Privilege Escalation Vulnerability · added February 4, 2022
- CVE-2022-22587Apple Memory Corruption Vulnerability · added January 28, 2022
- CVE-2018-13383 ransomwareFortinet FortiOS and FortiProxy Out-of-bounds Write · added January 10, 2022
- CVE-2021-35211 ransomwareSolarWinds Serv-U Remote Code Execution Vulnerability · added November 3, 2021
- CVE-2021-34448Microsoft Windows Scripting Engine Memory Corruption Vulnerability · added November 3, 2021
- CVE-2021-33742Microsoft Windows MSHTML Platform Remote Code Execution Vulnerability · added November 3, 2021
- CVE-2021-31956Microsoft Windows NTFS Privilege Escalation Vulnerability · added November 3, 2021
- CVE-2021-31755Tenda AC11 Router Stack Buffer Overflow Vulnerability · added November 3, 2021
- CVE-2021-30807Apple Multiple Products Memory Corruption Vulnerability · added November 3, 2021
- CVE-2021-30761Apple iOS WebKit Memory Corruption Vulnerability · added November 3, 2021
- CVE-2021-30665Apple Multiple Products WebKit Memory Corruption Vulnerability · added November 3, 2021
- CVE-2021-28664Arm Mali Graphics Processing Unit (GPU) Unspecified Vulnerability · added November 3, 2021
- CVE-2021-28310Microsoft Win32k Privilege Escalation Vulnerability · added November 3, 2021
- CVE-2021-27562Arm Trusted Firmware Out-of-Bounds Write Vulnerability · added November 3, 2021
- CVE-2021-1732 ransomwareMicrosoft Win32k Privilege Escalation Vulnerability · added November 3, 2021
- CVE-2020-27930Apple Multiple Products Memory Corruption Vulnerability · added November 3, 2021
- CVE-2020-16013Google Chromium V8 Incorrect Implementation Vulnerabililty · added November 3, 2021
- CVE-2020-16010Google Chrome for Android UI Heap Buffer Overflow Vulnerability · added November 3, 2021
- CVE-2020-16009Google Chromium V8 Type Confusion Vulnerability · added November 3, 2021
- CVE-2020-15999Google Chrome FreeType Heap Buffer Overflow Vulnerability · added November 3, 2021
- CVE-2020-14871Oracle Solaris and Zettabyte File System (ZFS) Unspecified Vulnerability · added November 3, 2021
- CVE-2020-9819Apple iOS, iPadOS, and watchOS Memory Corruption Vulnerability · added November 3, 2021
- CVE-2020-9818Apple iOS, iPadOS, and watchOS Out-of-Bounds Write Vulnerability · added November 3, 2021
- CVE-2020-1380Microsoft Internet Explorer Scripting Engine Memory Corruption Vulnerability · added November 3, 2021
- CVE-2020-1054Microsoft Win32k Privilege Escalation Vulnerability · added November 3, 2021
- CVE-2020-1020Microsoft Windows Adobe Font Manager Library Remote Code Execution Vulnerability · added November 3, 2021
- CVE-2020-0986Microsoft Windows Kernel Privilege Escalation Vulnerability · added November 3, 2021
- CVE-2020-0968 ransomwareMicrosoft Internet Explorer Scripting Engine Memory Corruption Vulnerability · added November 3, 2021
- CVE-2020-0938Microsoft Windows Adobe Font Manager Library Remote Code Execution Vulnerability · added November 3, 2021
- CVE-2020-0878 ransomwareMicrosoft Edge and Internet Explorer Memory Corruption Vulnerability · added November 3, 2021
- CVE-2020-0069Mediatek Multiple Chipsets Insufficient Input Validation Vulnerability · added November 3, 2021
- CVE-2019-5544 ransomwareVMware ESXi and Horizon DaaS OpenSLP Heap-Based Buffer Overflow Vulnerability · added November 3, 2021
- CVE-2019-1429Microsoft Internet Explorer Scripting Engine Memory Corruption Vulnerability · added November 3, 2021
- CVE-2019-1367 ransomwareMicrosoft Internet Explorer Scripting Engine Memory Corruption Vulnerability · added November 3, 2021
- CVE-2018-8653Microsoft Internet Explorer Scripting Engine Memory Corruption Vulnerability · added November 3, 2021
- CVE-2018-0802 ransomwareMicrosoft Office Memory Corruption Vulnerability · added November 3, 2021
- CVE-2018-0798Microsoft Office Memory Corruption Vulnerability · added November 3, 2021
H2 Security
Found it in your code?
We review where it appears, fix it with your team, and check it was not already used against you.
Talk to our teamT Academy
Stop writing it in the first place
Learn to build software and systems without weaknesses like this one, with practice on real hosts in your browser, every objective checked on the machine.
Start freeSource: MITRE Common Weakness Enumeration, CWE version 4.19.1. CWE is a trademark of The MITRE Corporation.