CWEweakness

CWE-192 Integer Coercion Error

Medium Official page ↗
Abstraction
Variant
Structure
Simple
Status
Incomplete
Likelihood of exploit
Medium
Languages
C, C#, C++, Java
CWE version
5.0

Description

Integer coercion refers to a set of flaws pertaining to the type casting, extension, or truncation of primitive data types.

Common consequences

• Availability: DoS: Resource Consumption (CPU), DoS: Resource Consumption (Memory), DoS: Crash, Exit, or Restart — Integer coercion often leads to undefined states of execution resulting in infinite loops or crashes. • Integrity, Confidentiality, Availability: Execute Unauthorized Code or Commands — In some cases, integer coercion errors can lead to exploitable buffer overflow conditions, resulting in the execution of arbitrary code. • Integrity, Other: Other — Integer coercion errors result in an incorrect value being stored for the variable in question, or possible violating integrity of the data.

Potential mitigations

• [Requirements] A language which throws exceptions on ambiguous data casts might be chosen. • [Architecture and Design] Design objects and program flow such that multiple or complex casts are unnecessary • [Implementation] Ensure that any data type casting that you must use is entirely understood in order to reduce the plausibility of error in use.

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

Observed examples

• CVE-2022-2639: Chain: integer coercion error (CWE-192) prevents a return value from indicating an error, leading to out-of-bounds write (CWE-787)

Related

Observed example · CVE (1)

  • CVE-2022-2639 An integer coercion error was found in the openvswitch kernel module. vulnerability

Child of · CWE (1)

  • CWE-681 Incorrect Conversion between Numeric Types weakness

Referenced by CVE · weakness (7)

  • CVE-2026-86143 In xmlIO in libxml2 before 2.15.4, an inconsistency in xmlOutputWriteCallback and xmlBufUse causes negative lengths to reach write… vulnerability
  • CVE-2026-8275 A vulnerability was detected in bettercap up to 2.41.5. vulnerability
  • CVE-2026-8276 A flaw has been found in bettercap up to 2.41.5. vulnerability
  • CVE-2022-2639 An integer coercion error was found in the openvswitch kernel module. vulnerability
  • CVE-2014-125011 A vulnerability was found in FFmpeg 2.0. vulnerability
  • CVE-2014-125012 A vulnerability was found in FFmpeg 2.0. vulnerability
  • CVE-2021-32996 The FANUC R-30iA and R-30iB series controllers are vulnerable to integer coercion errors, which cause the device to crash. vulnerability

Referenced by CWE · can also be (1)

  • CWE-197 Numeric Truncation Error weakness