CWE-191: Integer Underflow (Wrap or Wraparound)
CWE版本: 4.18
更新日期: 2025-09-09
弱点描述
The product subtracts one value from another, such that the result is less than the minimum allowable integer value, which produces a value that is not equal to the correct result.
扩展描述
This can happen in signed and unsigned cases.
常见后果
影响范围: Availability
技术影响: DoS: Crash, Exit, or Restart DoS: Resource Consumption (CPU) DoS: Resource Consumption (Memory) DoS: Instability
说明: This weakness will generally lead to undefined behavior and therefore crashes. In the case of overflows involving loop index variables, the likelihood of infinite loops is also high.
影响范围: Integrity
技术影响: Modify Memory
说明: If the value in question is important to data (as opposed to flow), simple data corruption has occurred. Also, if the wrap around results in other conditions such as buffer overflows, further memory corruption may occur.
影响范围: Confidentiality Availability Access Control
技术影响: Execute Unauthorized Code or Commands Bypass Protection Mechanism
说明: This weakness can sometimes trigger buffer overflows which can be used to execute arbitrary code. This is usually outside the scope of a program's implicit security policy.
检测方法
方法: 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.)
有效性: High
观察示例
参考: CVE-2004-0816
Integer underflow in firewall via malformed packet.
参考: CVE-2004-1002
Integer underflow by packet with invalid length.
参考: CVE-2005-0199
Long input causes incorrect length calculation.
参考: CVE-2005-1891
Malformed icon causes integer underflow in loop counter variable.
引入模式
| 阶段 | 说明 |
|---|---|
| Implementation | - |
适用平台
编程语言
分类映射
| 分类名称 | 条目ID | 条目名称 | 映射适配度 |
|---|---|---|---|
| PLOVER | - | Integer underflow (wrap or wraparound) | - |
| Software Fault Patterns | SFP1 | Glitch in computation | - |
| CERT C Secure Coding | INT30-C | Ensure that unsigned integer operations do not wrap | Imprecise |
| CERT C Secure Coding | INT32-C | Ensure that operations on signed integers do not result in overflow | Imprecise |