CWE-192 · Słabość
Integer Coercion Error
- Abstrakcja
- Wariant
- Status
- Niekompletny
- Ryzyko wykorzystania
- średnie
- Dodano
- 19 lipca 2006
- Ostatnia zmiana
- 11 grudnia 2025
Opis
Integer coercion refers to a set of flaws pertaining to the type casting, extension, or truncation of primitive data types.
Several flaws fall under the category of integer coercion errors. For the most part, these errors in and of themselves result only in availability and data integrity issues. However, in some circumstances, they may result in other, more complicated security related flaws, such as buffer overflow conditions.
Skutki
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.
Zapobieganie
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 used is entirely understood in order to reduce the plausibility of error in use.
Przykłady podatności
- 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)
Słabość nadrzędna
Kiedy powstaje
- Implementation
Dotyczy
C, C++, Java, C#
Uwagi
Within C, it might be that "coercion" is semantically different than "casting", possibly depending on whether the programmer directly specifies the conversion, or if the compiler does it implicitly. This has implications for the presentation of this entry and others, such as CWE-681, and whether there is enough of a difference for these entries to be split.
Źródła
- 24 Deadly Sins of Software Security — Michael Howard, David LeBlanc, John Viega, "Sin 7: Integer Overflows." Page 119, McGraw-Hill, 2010
- The Art of Software Security Assessment — Mark Dowd, John McDonald, Justin Schuh, Chapter 6, "Sign Extension", Page 248, Addison Wesley, 2006
- The CLASP Application Security Process — Secure Software, Inc., 2005
Wpis z katalogu CWE 4.20.