CWE-192: Integer Coercion Error
Integer coercion refers to a set of flaws pertaining to the type casting, extension, or truncation of primitive data types.
How it's found
Integer Coercion Error is a specific, narrowly defined instance of a broader pattern. Testers confirm it with targeted code review and a proof-of-concept input that exercises the exact code path this weakness describes.
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.
Consequences
- 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.
- 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.
- Other: Integer coercion errors result in an incorrect value being stored for the variable in question.
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 used is entirely understood in order to reduce the plausibility of error in use.
Where this fits in a TurboPentest engagement
This weakness is not covered by the automated black-box pentest. IntegSec pentesters cover it in a manual engagement.
Frequently asked questions
What is CWE-192?
Integer coercion refers to a set of flaws pertaining to the type casting, extension, or truncation of primitive data types.
How do you find Integer Coercion Error?
Integer Coercion Error is a specific, narrowly defined instance of a broader pattern. Testers confirm it with targeted code review and a proof-of-concept input that exercises the exact code path this weakness describes.
What is the impact of CWE-192?
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. 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. Other: Integer coercion errors result in an incorrect value being stored for the variable in question.
Does TurboPentest test for Integer Coercion Error?
This weakness is not covered by the automated black-box pentest. IntegSec pentesters cover it in a manual engagement.
Related CWEs
Written and reviewed by
Michel Chamberland - Founder & CEO, IntegSec
CISSP, OSCP, OSCE, CEH, GIAC, CCSK · 20+ years in offensive security
Michel has spent 20+ years on offensive security teams including IBM X-Force Red and Trustwave SpiderLabs, leading penetration tests, red team engagements, and breach response for Fortune 500 customers. He is the founder of IntegSec and the architect of TurboPentest.
Find these issues before an attacker does
TurboPentest runs an agentic AI pentest against your target and reports findings with proof, from $99 per target.
Start a pentest