CWE-839Numeric Range Comparison Without Minimum Check

PUBLISHEDweakness record
released 2011-03-30 · last modified 2025-12-11

Metadata

CWE ID:
CWE-839
摘要:
Base
结构:
Simple
状态:
Incomplete
发布日期:
2011-03-30
更新日期:
2025-12-11

名称

Numeric Range Comparison Without Minimum Check

描述

The product checks a value to ensure that it is less than or equal to a maximum, but it does not also verify that the value is greater than or equal to the minimum.

Some products use signed integers or floats even when their values are only expected to be positive or 0. An input validation check might assume that the value is positive, and only check for the maximum value. If the value is negative, but the code assumes that the value is positive, this can produce an error. The error may have security consequences if the negative value is used for memory allocation, array access, buffer access, etc. Ultimately, the error could lead to a buffer overflow or other type of memory corruption. The use of a negative number in a positive-only context could have security implications for other types of resources. For example, a shopping cart might check that the user is not requesting more than 10 items, but a request for -3 items could cause the application to calculate a negative price and credit the attacker's account.

常见后果

范围:
Integrity, Confidentiality, Availability
影响:
Modify Application Data, Execute Unauthorized Code or Commands
注释:
An attacker could modify the structure of the message or data being sent to the downstream component, possibly injecting commands.
范围:
Availability
影响:
DoS: Resource Consumption (Other)
注释:
in some contexts, a negative value could lead to resource consumption.
范围:
Confidentiality, Integrity
影响:
Modify Memory, Read Memory
注释:
If a negative value is used to access memory, buffers, or other indexable structures, it could access memory outside the bounds of the buffer.

相关 CWE