356
Nature Type ID Name Page
MemberOf 1218 Memory Buffer Errors 2479
Applicable Platforms
Language : C (Prevalence = Undetermined)
Language : C++ (Prevalence = Undetermined)
Likelihood Of Exploit
High
Common Consequences
Scope Impact Likelihood
Integrity
Availability
Confidentiality
DoS: Crash, Exit, or Restart
Execute Unauthorized Code or Commands
Read Memory
Modify Memory
If 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-ofbounds
read or write (CWE-119), possibly causing a crash,
allowing arbitrary code execution, or exposing sensitive
data.
Detection Methods
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 potential errors in buffer calculations. 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.
Effectiveness = High
Detection techniques for buffer-related errors are more mature than for most other weakness
types.
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.
Effectiveness = Moderate
Without visibility into the code, black box methods may not be able to sufficiently distinguish this
weakness from others, requiring follow-up manual methods to diagnose the underlying problem.
Manual Analysis
Manual analysis can be useful for finding this weakness, but it might not achieve desired code
coverage within limited time constraints. This becomes difficult for weaknesses that must be
considered for all inputs, since the attack surface can be too large.
Manual Analysis
CWE Version 4.14
CWE-131: Incorrect Calculation of Buffer Size
CWE-131: Incorrect Calculation of Buffer Size