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.
Impact: DoS: Crash, Exit, or Restart, DoS: Resource Consumption (CPU), DoS: Resource Consumption (Memory), DoS: Instability — Notes: 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.
Impact: Modify Memory — Notes: 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.
Impact: Execute Unauthorized Code or Commands, Bypass Protection Mechanism — Notes: 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.
Potential Mitigations
N/A: Requirements specification: The choice could be made to use a language that is not susceptible to these issues. (N/A)
Architecture and Design: Provide clear upper and lower bounds on the scale of any protocols designed. (N/A)
Implementation: Perform validation on all incremented variables to ensure that they remain within reasonable bounds. (N/A)
Applicable Platforms
C (N/A, Often)
C++ (N/A, Often)
Demonstrative Examples
Intro: The following image processing code allocates a table for images.
Body: 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).
Relationship: The relationship between overflow and wrap-around needs to be examined more closely, since several entries (including CWE-190) are closely related.