CWE-197: Numeric Truncation Error

What is CWE-197?

CWE-197 is Numeric Truncation Error. The flaw arises when truncation errors occur when a primitive is cast to a primitive of a smaller size and data is lost in the conversion. The database currently holds 36 vulnerabilities mapped to CWE-197 and none of them are in the CISA Known Exploited Vulnerabilities catalog.

Analyzing data...

OWASP Top 10 Rank-
Related CVES (365 days)36
AbstractionBase
Likelihood of exploitLow

Vulnerabilities mapped to CWE-197

36 vulnerabilities1100% increase year over year

No data

No vulnerability data in CISA KEV for CWE-197

Official definition

ByMitre CWE

Truncation errors occur when a primitive is cast to a primitive of a smaller size and data is lost in the conversion.

When a primitive is cast to a smaller primitive, the high order bits of the large value are lost in the conversion, potentially resulting in an unexpected value that is not equal to the original value. This value may be required as an index into a buffer, a loop iterator, or simply necessary state data. In any case, the value cannot be trusted and the system will be in an undefined state. While this method may be employed viably to isolate the low bits of a value, this usage is rare, and truncation usually implies that an implementation error has occurred.

Characteristics

Modes of introduction

  • Implementation

Common consequences

ImpactScopeExplanation
Modify MemoryIntegrityThe true value of the data is lost and corrupted data is used.

Risk mitigations

  1. ImplementationEnsure that no casts, implicit or explicit, take place that move from a larger size primitive or a smaller size primitive.

Detection methods

MethodApproachEffectiveness
FuzzingFuzz 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.High
Automated Static AnalysisAutomated 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.)High

Representative vulnerabilities

Sources (2)

CWE™ Program, operated by The MITRE Corporation. Copyright © 2006–2026, The MITRE Corporation. The MITRE Corporation hereby grants you a non-exclusive, royalty-free license to use CWE for research, development, and commercial purposes. CWE Terms of Use.

Learn more

Run an in-depth assessment with complete web risk management

CyStack VulnScan continuously discovers assets, validates vulnerabilities, and helps security teams prioritize remediation across the organization.