CWE-789: Memory Allocation with Excessive Size Value
low-riskThe product allocates memory based on an untrusted, large size value, but it does not ensure that the size is within expected limits, allowing arbitrary amounts of memory to be allocated.
Common Consequences
Detection Methods
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 static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)
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].
Real-World Examples (10)
| CVE | CVSS | EPSS | KEV |
|---|---|---|---|
| CVE-2017-7651 | 7.5 | 23.2% | — |
| CVE-2022-30522 | 7.5 | 11.6% | — |
| CVE-2025-20165 | 7.5 | 3.1% | — |
| CVE-2025-27533 | 7.5 | 2.3% | — |
| CVE-2022-22188 | 7.5 | 1.8% | — |
| CVE-2018-12541 | 6.5 | 1.3% | — |
| CVE-2024-43484 | 7.5 | 1.2% | — |
| CVE-2017-7652 | 7.5 | 1.0% | — |
| CVE-2023-37279 | 7.5 | 0.9% | — |
| CVE-2023-3223 | 7.5 | 0.9% | — |