BaseDraft
CWE-131Incorrect Calculation of Buffer Size
Category: memory
Description
The product does not correctly calculate the size to be used when allocating a buffer, which could lead to a buffer overflow.
Common consequences· 1
- Integrity / Availability / Confidentiality — DoS: Crash, Exit, or Restart, Execute Unauthorized Code or Commands, Read Memory, Modify MemoryIf the incorrect calculation is used in the context of memory allocation, then the software may create a buffer that is smaller or larger than expected. If the allocated buffer is smaller than expected, this could lead to an out-of-bounds read or write (CWE-119), possibly causing a crash, allowing arbitrary code execution, or exposing sensitive data.
Potential mitigations· 5
- [Implementation]When allocating a buffer for the purpose of transforming, converting, or encoding an input, allocate enough memory to handle the largest possible encoding. For example, in a routine that converts "&" characters to "&" for HTML entity encoding, the output buffer needs to be at least 5 times as large as the input buffer.
- [Implementation]
- [Implementation]Perform input validation on any numeric input by ensuring that it is within the expected range. Enforce that the input meets both the minimum and maximum requirements for the expected range.
- [Architecture and Design]For any security checks that are performed on the client side, ensure that these checks are duplicated on the server side, in order to avoid CWE-602. Attackers can bypass the client-side checks by modifying values after the checks have been performed, or by changing the client to remove the client-side checks entirely. Then, these modified values would be submitted to the server.
- [Implementation]When processing structured incoming data containing a size field followed by raw data, identify and resolve any inconsistencies between the size field and the actual size of the data (CWE-130).
Related CAPEC attack patterns· 2
References
Exploits (incoming)2
| Type | Target | Confidence | Tier |
|---|---|---|---|
| AttackPattern | Buffer Overflow via Parameter Expansioncapec-47 | 100% | live |
| AttackPattern | Overflow Bufferscapec-100 | 100% | live |
(incoming)13
| Type | Target | Confidence | Tier |
|---|---|---|---|
| Vulnerability | CVE-2025-1861cve-2025-1861 | 0% | live |
| Vulnerability | CVE-2025-46688cve-2025-46688 | 0% | live |
| Vulnerability | CVE-2025-55297cve-2025-55297 | 0% | live |
| Vulnerability | CVE-2025-57807cve-2025-57807 | 0% | live |
| Vulnerability | CVE-2025-62550cve-2025-62550 | 0% | live |
| Vulnerability | CVE-2025-66216cve-2025-66216 | 0% | live |
| Vulnerability | CVE-2026-1188cve-2026-1188 | 0% | live |
| Vulnerability | CVE-2026-1949cve-2026-1949 | 0% | live |
| Vulnerability | CVE-2026-20911cve-2026-20911 | 0% | live |
| Vulnerability | CVE-2026-27820cve-2026-27820 | 0% | live |
| Vulnerability | CVE-2026-31970cve-2026-31970 | 0% | live |
| Vulnerability | CVE-2026-41676cve-2026-41676 | 0% | live |
| KEVEntry | Microsoft Windows Kernel Privilege Escalation Vulnerabilitykev-cve-2020-17087 | 0% | live |
Related by meaning· 6
Nearest entities by semantic similarity across the cs-graph corpus.