CWE-128: Wrap-around Error
Wrap around errors occur whenever a value is incremented past the maximum value for its type and therefore "wraps around" to a very small, negative, or undefined value.
Last updated
Wrap around errors occur whenever a value is incremented past the maximum value for its type and therefore "wraps around" to a very small, negative, or undefined value.
Last updated
CWE-128 (Wrap-around Error) is a base-level software weakness catalogued by MITRE in the Common Weakness Enumeration (CWE). It describes a recurring type of mistake that can lead to exploitable security vulnerabilities.
Due to how addition is performed by computers, if a primitive is incremented past the maximum value possible for its storage space, the system will not recognize this, and therefore increment each bit as if it still had extra space. Because of how negative numbers are represented in binary, primitives interpreted as signed may "wrap" to very large negative values.
5 recorded CVEs are caused by CWE-128 (Wrap-around Error). The highest-severity and most recent are shown first. 3 new CWE-128 CVEs have been recorded so far in 2026.
Vulnerabilities in IBM AIX and PowerVM VIOS
Multiple Cisco Products Snort 3 Generic Routing Encapsulation Denial of Service Vulnerabilities
concurrent-ruby: `ReentrantReadWriteLock` read-count overflow grants a write lock without exclusivity
What can happen when CWE-128 is exploited.
DoS: Crash, Exit, or Restart, DoS: Resource Consumption (CPU), DoS: Resource Consumption (Memory), DoS: Instability
Affects: Availability
This weakness will generally lead to undefined behavior and therefore crashes. In the case of overflows involving loop index variables, the likelihood of infinite loops is also high.
Modify Memory
Affects: Integrity
If the value in question is important to data (as opposed to flow), simple data corruption has occurred. Also, if the wrap around results in other conditions such as buffer overflows, further memory corruption may occur.
Execute Unauthorized Code or Commands, Bypass Protection Mechanism
Affects: Confidentiality, Availability, Access Control
This weakness can sometimes trigger buffer overflows which can be used to execute arbitrary code. This is usually outside the scope of a program's implicit security policy.
Typically introduced during these phases of the software lifecycle.
Languages
Practical mitigations for CWE-128, grouped by where in the lifecycle they apply.
Requirements specification: The choice could be made to use a language that is not susceptible to these issues.
Provide clear upper and lower bounds on the scale of any protocols designed.
Perform validation on all incremented variables to ensure that they remain within reasonable bounds.
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.)
Effectiveness: High
MITRE examples of the weakness in code.
The following image processing code allocates a table for images.
Vulnerable example
img_t table_ptr; /*struct containing img data, 10kB each*/
int num_imgs;
...
num_imgs = get_num_imgs();
table_ptr = (img_t*)malloc(sizeof(img_t)*num_imgs);
...This code intends to allocate a table of size num_imgs, however as num_imgs grows large, the calculation determining the size of the list will eventually overflow (CWE-190). This will result in a very small list to be allocated instead. If the subsequent code operates on the list as if it were num_imgs long, it may result in many types of out-of-bounds problems (CWE-119).
CAPEC attack patterns that exploit this weakness.
Common questions about CWE-128.
Weakness data is sourced from the MITRE CWE catalog (v4.21). CVE associations are aggregated and kept current by RadicalNotion.AI.
Get an alert when a new CWE-128 CVE affects your products, with AI-written analysis and remediation steps.