|
Weakness ID: 197
Vulnerability Mapping:
ALLOWED
This CWE ID may be used to map to real-world vulnerabilities
Abstraction: Base Base - a weakness that is still mostly independent of a resource or technology, but with sufficient details to provide specific methods for detection and prevention. Base level weaknesses typically describe issues in terms of 2 or 3 of the following dimensions: behavior, property, technology, language, and resource. |
This table specifies different individual consequences
associated with the weakness. The Scope identifies the application security area that is
violated, while the Impact describes the negative technical impact that arises if an
adversary succeeds in exploiting this weakness. The Likelihood provides information about
how likely the specific consequence is expected to be seen relative to the other
consequences in the list. For example, there may be high likelihood that a weakness will be
exploited to achieve a certain impact, but a low likelihood that it will be exploited to
achieve a different impact.
| Impact | Details |
|---|---|
|
Modify Memory |
Scope: Integrity
The true value of the data is lost and corrupted data is used.
|
| Phase(s) | Mitigation |
|---|---|
|
Implementation |
Ensure that no casts, implicit or explicit, take place that move from a larger size primitive or a smaller size primitive.
|
This table shows the weaknesses and high level categories that are related to this
weakness. These relationships are defined as ChildOf, ParentOf, MemberOf and give insight to
similar items that may exist at higher and lower levels of abstraction. In addition,
relationships such as PeerOf and CanAlsoBe are defined to show similar weaknesses that the user
may want to explore.
Relevant to the view "Research Concepts" (View-1000)
| Nature | Type | ID | Name |
|---|---|---|---|
| ChildOf |
|
681 | Incorrect Conversion between Numeric Types |
| CanAlsoBe |
|
192 | Integer Coercion Error |
| CanAlsoBe |
|
194 | Unexpected Sign Extension |
| CanAlsoBe |
|
195 | Signed to Unsigned Conversion Error |
| CanAlsoBe |
|
196 | Unsigned to Signed Conversion Error |
Relevant to the view "CISQ Quality Measures (2020)" (View-1305)
| Nature | Type | ID | Name |
|---|---|---|---|
| ChildOf |
|
681 | Incorrect Conversion between Numeric Types |
Relevant to the view "CISQ Data Protection Measures" (View-1340)
| Nature | Type | ID | Name |
|---|---|---|---|
| ChildOf |
|
681 | Incorrect Conversion between Numeric Types |
The different Modes of Introduction provide information
about how and when this
weakness may be introduced. The Phase identifies a point in the life cycle at which
introduction
may occur, while the Note provides a typical scenario related to introduction during the
given
phase.
| Phase | Note |
|---|---|
| Implementation |
This listing shows possible areas for which the given
weakness could appear. These
may be for specific named Languages, Operating Systems, Architectures, Paradigms,
Technologies,
or a class of such platforms. The platform is listed along with how frequently the given
weakness appears for that instance.
| Languages |
C (Undetermined Prevalence) C++ (Undetermined Prevalence) Java (Undetermined Prevalence) C# (Undetermined Prevalence) |
Example 1
This example, while not exploitable, shows the possible mangling of values associated with truncation errors:
The above code, when compiled and run on certain systems, returns the following output:
This problem may be exploitable when the truncated value is used as an array index, which can happen implicitly when 64-bit values are used as indexes, as they are truncated to 32 bits.
Example 2
In the following Java example, the method updateSalesForProduct is part of a business application class that updates the sales information for a particular product. The method receives as arguments the product ID and the integer amount sold. The product ID is used to retrieve the total product count from an inventory object which returns the count as an integer. Before calling the method of the sales object to update the sales count the integer values are converted to The primitive type short since the method requires short type for the method arguments.
However, a numeric truncation error can occur if the integer values are higher than the maximum value allowed for the primitive type short. This can cause unexpected results or loss or corruption of data. In this case the sales database may be corrupted with incorrect data. Explicit casting from a from a larger size primitive type to a smaller size primitive type should be prevented. The following example an if statement is added to validate that the integer values less than the maximum value for the primitive type short before the explicit cast and the call to the sales method.
Note: this is a curated list of examples for users to understand the variety of ways in which this weakness can be introduced. It is not a complete list of all CVEs that are related to this CWE entry.
| Reference | Description |
|---|---|
|
Integer truncation of length value leads to heap-based buffer overflow.
|
|
|
Size of a particular type changes for 64-bit platforms, leading to an integer truncation in document processor causes incorrect index to be generated.
|
| Ordinality | Description |
|---|---|
|
Primary
|
(where the weakness exists independent of other weaknesses)
|
Resultant
|
(where the weakness is typically related to the presence of some other weaknesses)
|
| Method | Details |
|---|---|
|
Fuzzing |
Fuzz testing (fuzzing) is a powerful technique for generating large numbers of diverse inputs - either randomly or algorithmically - and dynamically invoking the code with those inputs. Even with random inputs, it is often capable of generating unexpected results such as crashes, memory corruption, or resource consumption. Fuzzing effectively produces repeatable test cases that clearly indicate bugs, which helps developers to diagnose the issues.
Effectiveness: High |
|
Automated Static Analysis |
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 |
This MemberOf Relationships table shows additional CWE Categories and Views that
reference this weakness as a member. This information is often useful in understanding where a
weakness fits within the context of external information sources.
| Nature | Type | ID | Name |
|---|---|---|---|
| MemberOf | 738 | CERT C Secure Coding Standard (2008) Chapter 5 - Integers (INT) | |
| MemberOf | 848 | The CERT Oracle Secure Coding Standard for Java (2011) Chapter 5 - Numeric Types and Operations (NUM) | |
| MemberOf | 872 | CERT C++ Secure Coding Section 04 - Integers (INT) | |
| MemberOf | 998 | SFP Secondary Cluster: Glitch in Computation | |
| MemberOf | 1137 | SEI CERT Oracle Secure Coding Standard for Java - Guidelines 03. Numeric Types and Operations (NUM) | |
| MemberOf | 1158 | SEI CERT C Coding Standard - Guidelines 04. Integers (INT) | |
| MemberOf | 1159 | SEI CERT C Coding Standard - Guidelines 05. Floating Point (FLP) | |
| MemberOf | 1163 | SEI CERT C Coding Standard - Guidelines 09. Input Output (FIO) | |
| MemberOf | 1416 | Comprehensive Categorization: Resource Lifecycle Management |
| Usage |
ALLOWED
(this CWE ID may be used to map to real-world vulnerabilities)
|
| 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. |
Research Gap
| Mapped Taxonomy Name | Node ID | Fit | Mapped Node Name |
|---|---|---|---|
| PLOVER | Numeric truncation error | ||
| CLASP | Truncation error | ||
| CERT C Secure Coding | FIO34-C | CWE More Abstract | Distinguish between characters read from a file and EOF or WEOF |
| CERT C Secure Coding | FLP34-C | CWE More Abstract | Ensure that floating point conversions are within range of the new type |
| CERT C Secure Coding | INT02-C | Understand integer conversion rules | |
| CERT C Secure Coding | INT05-C | Do not use input functions to convert character data if they cannot handle all possible inputs | |
| CERT C Secure Coding | INT31-C | CWE More Abstract | Ensure that integer conversions do not result in lost or misinterpreted data |
| The CERT Oracle Secure Coding Standard for Java (2011) | NUM12-J | Ensure conversions of numeric types to narrower types do not result in lost or misinterpreted data | |
| Software Fault Patterns | SFP1 | Glitch in computation |
| [REF-62] | Mark Dowd, John McDonald and Justin Schuh. "The Art of Software Security Assessment". Chapter 6, "Truncation", Page 259. 1st Edition. Addison Wesley. 2006. |
|
Use of the Common Weakness Enumeration (CWE™) and the associated references from this website are subject to the Terms of Use. CWE is sponsored by the U.S. Department of Homeland Security (DHS) Cybersecurity and Infrastructure Security Agency (CISA) and managed by the Homeland Security Systems Engineering and Development Institute (HSSEDI) which is operated by The MITRE Corporation (MITRE). Copyright © 2006–2026, The MITRE Corporation. CWE, CWSS, CWRAF, and the CWE logo are trademarks of The MITRE Corporation. |
||
