CWE-197: Numeric Truncation Error

low-risk

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

Abstraction: Base

Common Consequences

Integrity Modify Memory

Detection Methods

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.

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

Real-World Examples (10)

CVE CVSS EPSS KEV
CVE-2022-42475 9.8 94.0% Y
CVE-2024-29050 8.4 37.9%
CVE-2024-49018 8.8 10.0%
CVE-2024-38125 7.8 9.4%
CVE-2024-43519 8.8 7.1%
CVE-2024-30009 8.8 4.8%
CVE-2024-38044 7.2 4.8%
CVE-2024-21310 7.8 4.1%
CVE-2024-43639 9.8 3.0%
CVE-2024-28944 8.8 2.6%
6
/ 100
low-risk
Active Threat 5/50 · Minimal
Exploit Availability 1/50 · Minimal