CWE-681: Incorrect Conversion between Numeric Types

low-risk

When converting from one data type to another, such as long to integer, data can be omitted or translated in a way that produces unexpected values. If the resulting values are used in a sensitive context, then dangerous behaviors may occur.

Abstraction: Base

Common Consequences

Other Unexpected State

Detection Methods

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-2017-7308 7.8 87.0%
CVE-2009-0231 8.8 65.0%
CVE-2016-3074 9.8 54.7%
CVE-2023-23388 8.8 17.7%
CVE-2022-43663 8.1 16.8%
CVE-2018-1000224 7.5 13.2%
CVE-2023-46848 8.6 10.4%
CVE-2023-46848 8.6 10.4%
CVE-2018-8786 9.8 9.6%
CVE-2018-5711 5.5 7.8%
6
/ 100
low-risk
Active Threat 6/50 · Minimal
Exploit Availability 0/50 · Minimal