CWE-839 - Numeric Range Comparison Without Minimum Check
CWE-839
- Abstraction:
- Base
- Structure:
- Simple
- Status:
- Incomplete
- Weakness Name
Numeric Range Comparison Without Minimum Check
- Description
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.
- Common Consequences
Scope: Integrity, Confidentiality, Availability
Impact: Modify Application Data, Execute Unauthorized Code or Commands
Notes: An attacker could modify the structure of the message or data being sent to the downstream component, possibly injecting commands.
Scope: Availability
Impact: DoS: Resource Consumption (Other)
Notes: in some contexts, a negative value could lead to resource consumption.
Scope: Confidentiality, Integrity
Impact: Modify Memory, Read Memory
Notes: If a negative value is used to access memory, buffers, or other indexable structures, it could access memory outside the bounds of the buffer.
- Related Weaknesses
- Release Date:
- 2011-03-30
- Latest Modification Date:
- 2023-10-26
Free security scan for your website