CWE-839: Numeric Range Comparison Without Minimum Check

BaseIncomplete

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.

View on MITRE
Back to CWE Lookup

Extended Description

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.

Technical Details

Structure
Simple
Vulnerability Mapping
ALLOWED

Applicable To

Languages
CC++
Platforms

Source-backed guidance

Additional facts reviewed against primary or authoritative security sources.

Verify controls for CWE-839 with SSDF evidence

Use NIST SSDF verification and vulnerability-response practices to detect CWE-839, Numeric Range Comparison Without Minimum Check, throughout the product lifecycle. Derive review questions, static or dynamic checks, and negative tests from the CWE's causal behavior; define the components and lifecycle stages each check covers; and retain findings with enough evidence to distinguish the root cause from symptoms and impacts. Track escapes and false negatives, then improve the verification plan after every confirmed occurrence.

NIST SP 800-218 Secure Software Development FrameworkNational Institute of Standards and Technology

Apply Enforcement by Conversion controls for Numeric Range Comparison Without Minimum Check

MITRE associates mitigation with Implementation; the listed strategies include Enforcement by Conversion, and Input Validation; documented detection approaches include Automated Static Analysis. Use these source-defined anchors to turn CWE-839 into implementation, review, and verification checks for the affected component.

CWE-839: Numeric Range Comparison Without Minimum CheckMITRE CWE

Triage CWE-839 against known exploitation evidence

Use CISA's Known Exploited Vulnerabilities catalog to test whether a vulnerability mapped to CWE-839, Numeric Range Comparison Without Minimum Check, has evidence of exploitation in the wild. Confirm the CVE-to-CWE root-cause mapping independently before attaching the example, then capture the affected product, required action, and remediation deadline. A missing KEV match is not evidence that the weakness is unexploited, and a KEV entry must not be generalized to every occurrence of this CWE.

Known Exploited Vulnerabilities CatalogCybersecurity and Infrastructure Security Agency

Apply precise root-cause mapping to CWE-839

Apply MITRE's full root-cause mapping guidance when using CWE-839, Numeric Range Comparison Without Minimum Check. Separate weakness language from attacker prerequisites and technical impact, check the entry's abstraction and vulnerability-mapping notes, and prefer the most specific Base or Variant supported by the evidence. Record the rejected alternatives and require an independent review before the mapping is used for remediation trends or program metrics.

CVE to CWE Root Cause Mapping GuidanceMITRE CWE

Validate CWE-839 with root-cause mapping checks

Apply MITRE's root-cause mapping quick tips to CWE-839, Numeric Range Comparison Without Minimum Check. Confirm the finding describes the causal weakness rather than an impact or attack pattern, compare the abstraction and mapping notes with plausible alternatives, and have a second reviewer challenge the selection. Preserve the evidence and reasoning so recurring defects can be measured against one consistent identifier.

CVE to CWE Root Cause Mapping Quick TipsMITRE CWE

Frequently Asked Questions

What is CWE-839: Numeric Range Comparison Without Minimum Check?+

CWE-839: Numeric Range Comparison Without Minimum Check is a Common Weakness Enumeration (CWE) entry maintained by MITRE. 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.

What are the security consequences of Numeric Range Comparison Without Minimum Check?+

If exploited, CWE-839 (Numeric Range Comparison Without Minimum Check) it can compromise Integrity, Confidentiality and Availability, leading to outcomes such as Modify Application Data, Execute Unauthorized Code or Commands, DoS: Resource Consumption (Other), Modify Memory and Read Memory.

How do you prevent or mitigate Numeric Range Comparison Without Minimum Check?+

Recommended mitigations for CWE-839 include: If the number to be used is always expected to be positive, change the variable type from signed to unsigned or size_t. If the number to be used could have a negative value based on the specification (thus requiring a signed value), but the number should only be positive to preserve code correctness, then include a check to ensure that the value is positive.

Which programming languages are affected by Numeric Range Comparison Without Minimum Check?+

CWE-839 commonly affects C and C++. Note that weaknesses are often language-agnostic patterns, so secure coding practices apply broadly.

What are real-world examples of Numeric Range Comparison Without Minimum Check?+

MITRE documents real CVEs mapped to CWE-839, including CVE-2010-1866, CVE-2009-1099, CVE-2011-0521, CVE-2010-3704 and CVE-2010-2530. You can look up the full details of each CVE, including CVSS scores and remediation guidance, on our CVE Lookup tool.

What is the difference between a CWE and a CVE?+

A CWE (Common Weakness Enumeration) like CWE-839 describes a category of software weakness — the underlying flaw type. A CVE (Common Vulnerabilities and Exposures) identifies a specific, real-world vulnerability in a particular product. In short, a CWE is the kind of mistake, and a CVE is an instance of that mistake being found in software.

Learn More

Advertisement