CWE-191 整数下溢(超界折返)

Integer Underflow (Wrap or Wraparound)

结构: Simple

Abstraction: Base

状态: Draft

被利用可能性: unkown

基本描述

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.

相关缺陷

  • cwe_Nature: ChildOf cwe_CWE_ID: 682 cwe_View_ID: 1000 cwe_Ordinal: Primary

  • cwe_Nature: ChildOf cwe_CWE_ID: 682 cwe_View_ID: 1003 cwe_Ordinal: Primary

  • cwe_Nature: ChildOf cwe_CWE_ID: 682 cwe_View_ID: 699 cwe_Ordinal: Primary

适用平台

Language: [{'cwe_Name': 'C', 'cwe_Prevalence': 'Undetermined'}, {'cwe_Name': 'C++', 'cwe_Prevalence': 'Undetermined'}, {'cwe_Name': 'Java', 'cwe_Prevalence': 'Undetermined'}, {'cwe_Name': 'C#', 'cwe_Prevalence': 'Undetermined'}]

常见的影响

范围 影响 注释
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.

示例代码

The following example subtracts from a 32 bit signed integer.

bad C

#include <stdio.h>
#include <stdbool.h>
main (void)
{
int i;
i = -2147483648;
i = i - 1;
return 0;
}

The example has an integer underflow. The value of i is already at the lowest negative value possible, so after subtracting 1, the new value of i is 2147483647.

分析过的案例

标识 说明 链接
CVE-2004-0816 Integer underflow in firewall via malformed packet. https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2004-0816
CVE-2004-1002 Integer underflow by packet with invalid length. https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2004-1002
CVE-2005-0199 Long input causes incorrect length calculation. https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2005-0199
CVE-2005-1891 Malformed icon causes integer underflow in loop counter variable. https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2005-1891

Notes

分类映射

映射的分类名 ImNode ID Fit Mapped Node Name
PLOVER Integer underflow (wrap or wraparound)
Software Fault Patterns SFP1 Glitch in computation
CERT C Secure Coding INT30-C Imprecise Ensure that unsigned integer operations do not wrap
CERT C Secure Coding INT32-C Imprecise Ensure that operations on signed integers do not result in overflow

引用