Logo
-

Byte Open Security

(ByteOS Network)

Log In

Sign Up

ByteOS

Security
Vulnerability Details
Registries
Custom Views
Weaknesses
Attack Patterns
Filters & Tools
CWE-128:Wrap-around Error
Weakness ID:128
Version:v4.17
Weakness Name:Wrap-around Error
Vulnerability Mapping:Allowed
Abstraction:Base
Structure:Simple
Status:Incomplete
Likelihood of Exploit:Medium
DetailsContent HistoryObserved CVE ExamplesReports
▼Description

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.

▼Extended Description

▼Alternate Terms
▼Relationships
Relevant to the view"Research Concepts - (1000)"
NatureMappingTypeIDName
CanPrecedeDiscouragedC119Improper Restriction of Operations within the Bounds of a Memory Buffer
ChildOfDiscouragedP682Incorrect Calculation
PeerOfAllowedB190Integer Overflow or Wraparound
Nature: CanPrecede
Mapping: Discouraged
Type: Class
ID: 119
Name: Improper Restriction of Operations within the Bounds of a Memory Buffer
Nature: ChildOf
Mapping: Discouraged
Type: Pillar
ID: 682
Name: Incorrect Calculation
Nature: PeerOf
Mapping: Allowed
Type: Base
ID: 190
Name: Integer Overflow or Wraparound
▼Memberships
NatureMappingTypeIDName
MemberOfProhibitedC189Numeric Errors
MemberOfProhibitedC742CERT C Secure Coding Standard (2008) Chapter 9 - Memory Management (MEM)
MemberOfProhibitedC876CERT C++ Secure Coding Section 08 - Memory Management (MEM)
MemberOfProhibitedC998SFP Secondary Cluster: Glitch in Computation
MemberOfProhibitedC1408Comprehensive Categorization: Incorrect Calculation
Nature: MemberOf
Mapping: Prohibited
Type:Category
ID: 189
Name: Numeric Errors
Nature: MemberOf
Mapping: Prohibited
Type:Category
ID: 742
Name: CERT C Secure Coding Standard (2008) Chapter 9 - Memory Management (MEM)
Nature: MemberOf
Mapping: Prohibited
Type:Category
ID: 876
Name: CERT C++ Secure Coding Section 08 - Memory Management (MEM)
Nature: MemberOf
Mapping: Prohibited
Type:Category
ID: 998
Name: SFP Secondary Cluster: Glitch in Computation
Nature: MemberOf
Mapping: Prohibited
Type:Category
ID: 1408
Name: Comprehensive Categorization: Incorrect Calculation
▼Tags
NatureMappingTypeIDName
MemberOfProhibitedBSBOSS-273Medium likelihood of exploit
MemberOfProhibitedBSBOSS-311Execute Unauthorized Code or Commands (impact)
MemberOfProhibitedBSBOSS-314DoS: Resource Consumption (CPU) (impact)
MemberOfProhibitedBSBOSS-316Bypass Protection Mechanism (impact)
MemberOfProhibitedBSBOSS-324DoS: Crash, Exit, or Restart (impact)
MemberOfProhibitedBSBOSS-327DoS: Resource Consumption (Memory) (impact)
MemberOfProhibitedBSBOSS-329DoS: Instability (impact)
MemberOfProhibitedBSBOSS-331Modify Memory (impact)
Nature: MemberOf
Mapping: Prohibited
Type:BOSSView
ID: BOSS-273
Name: Medium likelihood of exploit
Nature: MemberOf
Mapping: Prohibited
Type:BOSSView
ID: BOSS-311
Name: Execute Unauthorized Code or Commands (impact)
Nature: MemberOf
Mapping: Prohibited
Type:BOSSView
ID: BOSS-314
Name: DoS: Resource Consumption (CPU) (impact)
Nature: MemberOf
Mapping: Prohibited
Type:BOSSView
ID: BOSS-316
Name: Bypass Protection Mechanism (impact)
Nature: MemberOf
Mapping: Prohibited
Type:BOSSView
ID: BOSS-324
Name: DoS: Crash, Exit, or Restart (impact)
Nature: MemberOf
Mapping: Prohibited
Type:BOSSView
ID: BOSS-327
Name: DoS: Resource Consumption (Memory) (impact)
Nature: MemberOf
Mapping: Prohibited
Type:BOSSView
ID: BOSS-329
Name: DoS: Instability (impact)
Nature: MemberOf
Mapping: Prohibited
Type:BOSSView
ID: BOSS-331
Name: Modify Memory (impact)
▼Relevant To View
Relevant to the view"Software Development - (699)"
NatureMappingTypeIDName
MemberOfProhibitedC189Numeric Errors
Nature: MemberOf
Mapping: Prohibited
Type: Category
ID: 189
Name: Numeric Errors
Relevant to the view"Software Fault Pattern (SFP) Clusters - (888)"
NatureMappingTypeIDName
MemberOfProhibitedC998SFP Secondary Cluster: Glitch in Computation
Nature: MemberOf
Mapping: Prohibited
Type: Category
ID: 998
Name: SFP Secondary Cluster: Glitch in Computation
▼Background Detail

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.

▼Common Consequences
ScopeLikelihoodImpactNote
AvailabilityN/ADoS: Crash, Exit, or RestartDoS: Resource Consumption (CPU)DoS: Resource Consumption (Memory)DoS: Instability

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.

IntegrityN/AModify Memory

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.

ConfidentialityAvailabilityAccess ControlN/AExecute Unauthorized Code or CommandsBypass Protection Mechanism

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.

Scope: Availability
Likelihood: N/A
Impact: DoS: Crash, Exit, or Restart, DoS: Resource Consumption (CPU), DoS: Resource Consumption (Memory), DoS: Instability
Note:

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.

Scope: Integrity
Likelihood: N/A
Impact: Modify Memory
Note:

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.

Scope: Confidentiality, Availability, Access Control
Likelihood: N/A
Impact: Execute Unauthorized Code or Commands, Bypass Protection Mechanism
Note:

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
Phase:
Mitigation ID:
Strategy:
Effectiveness:
Description:

Requirements specification: The choice could be made to use a language that is not susceptible to these issues.

Note:


Phase:Architecture and Design
Mitigation ID:
Strategy:
Effectiveness:
Description:

Provide clear upper and lower bounds on the scale of any protocols designed.

Note:


Phase:Implementation
Mitigation ID:
Strategy:
Effectiveness:
Description:

Perform validation on all incremented variables to ensure that they remain within reasonable bounds.

Note:

▼Modes Of Introduction
Phase: Implementation
Note:

N/A

▼Applicable Platforms
Languages
Class: C(Often Prevalence)
Class: C++(Often Prevalence)
▼Demonstrative Examples
Example 1

The following image processing code allocates a table for images.

Language: ( code)
N/A

Language: C(Bad code)
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); ...

Language: ( code)
N/A

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).

▼Observed Examples
ReferenceDescription
▼Affected Resources
    ▼Functional Areas
      ▼Weakness Ordinalities
      OrdinalityDescription
      Primary
      N/A
      Ordinality: Primary
      Description:
      N/A
      ▼Detection Methods
      ▼Vulnerability Mapping Notes
      Usage:Allowed
      Reason:Acceptable-Use
      Rationale:

      This CWE entry is at the Base level of abstraction, which is a preferred level of abstraction for mapping to the root causes of vulnerabilities.

      Comments:

      Carefully read both the name and description to ensure that this mapping is an appropriate fit. Do not try to 'force' a mapping to a lower-level Base/Variant simply to comply with this preferred level of abstraction.

      Suggestions:
      ▼Notes
      Relationship

      The relationship between overflow and wrap-around needs to be examined more closely, since several entries (including CWE-190) are closely related.

      N/A

      ▼Taxonomy Mappings
      Taxonomy NameEntry IDFitEntry Name
      CLASPN/AN/AWrap-around error
      CERT C Secure CodingMEM07-CN/AEnsure that the arguments to calloc(), when multiplied, can be represented as a size_t
      Software Fault PatternsSFP1N/AGlitch in computation
      Taxonomy Name: CLASP
      Entry ID: N/A
      Fit: N/A
      Entry Name: Wrap-around error
      Taxonomy Name: CERT C Secure Coding
      Entry ID: MEM07-C
      Fit: N/A
      Entry Name: Ensure that the arguments to calloc(), when multiplied, can be represented as a size_t
      Taxonomy Name: Software Fault Patterns
      Entry ID: SFP1
      Fit: N/A
      Entry Name: Glitch in computation
      ▼Related Attack Patterns
      IDName
      CAPEC-92
      Forced Integer Overflow
      ID: CAPEC-92
      Name: Forced Integer Overflow
      ▼References
      Reference ID: REF-44
      Title: 24 Deadly Sins of Software Security
      Author: Michael Howard, David LeBlanc, John Viega
      Section: "Sin 5: Buffer Overruns." Page 89
      Publication:
      McGraw-Hill
      Publisher:
      Edition:
      URL:
      URL Date:
      Day:N/A
      Month:N/A
      Year:2010
      Reference ID: REF-62
      Title: The Art of Software Security Assessment
      Author: Mark Dowd, John McDonald, Justin Schuh
      Section: Chapter 6, "Signed Integer Boundaries", Page 220
      Publication:
      Publisher:Addison Wesley
      Edition:1st Edition
      URL:
      URL Date:
      Day:N/A
      Month:N/A
      Year:2006
      Reference ID: REF-18
      Title: The CLASP Application Security Process
      Author: Secure Software, Inc.
      Section:
      Publication:
      Publisher:
      Edition:
      URL:https://cwe.mitre.org/documents/sources/TheCLASPApplicationSecurityProcess.pdf
      URL Date:2024-11-17
      Day:N/A
      Month:N/A
      Year:2005
      Details not found