CWE-1284 Base Incomplet

Improper Validation of Specified Quantity in Input

This vulnerability occurs when an application accepts user input meant to define a quantity—like a number, size, or count—but fails to properly check if that value is safe and reasonable before…

Définition

What is CWE-1284?

This vulnerability occurs when an application accepts user input meant to define a quantity—like a number, size, or count—but fails to properly check if that value is safe and reasonable before using it.
Applications constantly handle user-defined quantities: file sizes to upload, lengths for arrays, loop iteration counts, or prices for transactions. If your code trusts these numbers without scrutiny, it can be tricked into performing dangerous actions. Attackers exploit this by submitting extreme or malicious values—like a negative number, an impossibly large size, or zero—to manipulate the program's logic, crash it, or force it into an unstable state. Failing to validate quantities has direct consequences. Your application might allocate all available memory based on a huge size, perform a calculation that leads to an integer overflow, or enter an infinite loop. This opens the door to denial-of-service, buffer overflows, or logic flaws that compromise security. Always treat any user-supplied quantity as untrusted and enforce strict rules for minimums, maximums, and expected ranges before the value is used in any operation.
Impact réel

Real-world CVEs caused by CWE-1284

  • Chain: Python library does not limit the resources used to process images that specify a very large number of bands (CWE-1284), leading to excessive memory consumption (CWE-789) or an integer overflow (CWE-190).

  • lack of validation of length field leads to infinite loop

  • lack of validation of string length fields allows memory consumption or buffer over-read

Comment les attaquants l'exploitent

Parcours de l'attaquant étape par étape

  1. 1

    This example demonstrates a shopping interaction in which the user is free to specify the quantity of items to be purchased and a total is calculated.

  2. 2

    The user has no control over the price variable, however the code does not prevent a negative value from being specified for quantity. If an attacker were to provide a negative value, then the user would have their account credited instead of debited.

  3. 3

    This example asks the user for a height and width of an m X n game board with a maximum dimension of 100 squares.

  4. 4

    While this code checks to make sure the user cannot specify large, positive integers and consume too much memory, it does not check for negative values supplied by the user. As a result, an attacker can perform a resource consumption (CWE-400) attack against this program by specifying two, large negative values that will not overflow, resulting in a very large memory allocation (CWE-789) and possibly a system crash. Alternatively, an attacker can provide very large negative values which will cause an integer overflow (CWE-190) and unexpected behavior will follow depending on how the values are treated in the remainder of the program.

Exemple de code vulnérable

Vulnerable Java

This example demonstrates a shopping interaction in which the user is free to specify the quantity of items to be purchased and a total is calculated.

Vulnérable Java
...
  public static final double price = 20.00;
  int quantity = currentUser.getAttribute("quantity");
  double total = price * quantity;
  chargeUser(total);
  ...
Exemple de code sécurisé

Secure pseudo

Sécurisé pseudo
// Validate, sanitize, or use a safe API before reaching the sink.
function handleRequest(input) {
  const safe = validateAndEscape(input);
  return executeWithGuards(safe);
}
What changed: the unsafe sink is replaced (or the input is validated/escaped) so the same payload no longer triggers the weakness.
Liste de contrôle de prévention

How to prevent CWE-1284

  • Implementation Assume all input is malicious. Use an "accept known good" input validation strategy, i.e., use a list of acceptable inputs that strictly conform to specifications. Reject any input that does not strictly conform to specifications, or transform it into something that does. When performing input validation, consider all potentially relevant properties, including length, type of input, the full range of acceptable values, missing or extra inputs, syntax, consistency across related fields, and conformance to business rules. As an example of business rule logic, "boat" may be syntactically valid because it only contains alphanumeric characters, but it is not valid if the input is only expected to contain colors such as "red" or "blue." Do not rely exclusively on looking for malicious or malformed inputs. This is likely to miss at least one undesirable input, especially if the code's environment changes. This can give attackers enough room to bypass the intended validation. However, denylists can be useful for detecting potential attacks or determining which inputs are so malformed that they should be rejected outright.
Signaux de détection

How to detect CWE-1284

SAST High

Exécuter une analyse statique (SAST) sur le code source à la recherche du motif non sécurisé dans le flux de données.

DAST Moderate

Exécuter des tests de sécurité applicative dynamique (DAST) contre le point de terminaison en ligne.

Runtime Moderate

Surveiller les journaux runtime pour détecter des traces d'exception inhabituelles, des entrées malformées ou des tentatives de contournement d'autorisation.

Code review Moderate

Revue de code : signaler tout nouveau code qui traite les entrées de cette surface sans utiliser les helpers du framework validés.

Correction automatique Plexicus

Plexicus détecte automatiquement CWE-1284 et ouvre une PR de correction en moins de 60 secondes.

Codex Remedium analyse chaque commit, identifie cette faiblesse précise et livre une pull request prête à être relue avec le correctif. Pas de tickets. Pas de transferts.

Questions fréquentes

Frequently asked questions

Qu'est-ce que CWE-1284 ?

This vulnerability occurs when an application accepts user input meant to define a quantity—like a number, size, or count—but fails to properly check if that value is safe and reasonable before using it.

Quelle est la gravité de CWE-1284 ?

MITRE n'a pas publié de note de probabilité d'exploitation pour cette faiblesse. Traitez-la comme un impact moyen jusqu'à ce que votre modèle de menace prouve le contraire.

Quels langages ou plateformes sont affectés par CWE-1284 ?

MITRE n'a pas spécifié les plateformes affectées pour ce CWE — il peut s'appliquer à la plupart des stacks applicatives.

Comment puis-je prévenir CWE-1284 ?

Assume all input is malicious. Use an "accept known good" input validation strategy, i.e., use a list of acceptable inputs that strictly conform to specifications. Reject any input that does not strictly conform to specifications, or transform it into something that does. When performing input validation, consider all potentially relevant properties, including length, type of input, the full range of acceptable values, missing or extra inputs, syntax, consistency across related fields, and…

Comment Plexicus détecte et corrige CWE-1284 ?

Le moteur SAST de Plexicus reconnaît la signature de flux de données de CWE-1284 à chaque commit. Lorsqu'une correspondance est trouvée, notre agent Codex Remedium ouvre une PR de correction avec le code corrigé, les tests et un résumé d'une ligne pour le relecteur.

Où puis-je en savoir plus sur CWE-1284 ?

MITRE publie la définition canonique à https://cwe.mitre.org/data/definitions/1284.html. Vous pouvez également consulter la documentation OWASP et NIST pour des conseils adjacents.

Faiblesses associées

Weaknesses related to CWE-1284

CWE-20 Parent

Improper Input Validation

This vulnerability occurs when an application accepts data from an external source but fails to properly verify that the data is safe and…

CWE-102 Frère

Struts: Duplicate Validation Forms

This vulnerability occurs when an application defines multiple Struts validation forms with identical names. The framework then…

CWE-103 Frère

Struts: Incomplete validate() Method Definition

This vulnerability occurs in a Struts application when a validator form either completely omits a validate() method or includes one but…

CWE-104 Frère

Struts: Form Bean Does Not Extend Validation Class

This vulnerability occurs in Apache Struts applications when a form bean class does not properly extend the framework's validation class.…

CWE-105 Frère

Struts: Form Field Without Validator

This vulnerability occurs when a Struts application form contains an input field that lacks a corresponding validator, leaving it open to…

CWE-106 Frère

Struts: Plug-in Framework not in Use

This weakness occurs when a Java application, particularly one using the Struts framework, does not implement a structured input…

CWE-107 Frère

Struts: Unused Validation Form

This vulnerability occurs when a Struts application contains validation form definitions that are no longer linked to any active form or…

CWE-108 Frère

Struts: Unvalidated Action Form

In Apache Struts, every Action Form that processes user input must have a corresponding validation form configured. Missing this…

CWE-109 Frère

Struts: Validator Turned Off

This vulnerability occurs when an application built with Apache Struts intentionally disables its built-in validation framework. By…

Prêt quand vous l'êtes

Arrêtez de payer par développeur.
Commencez à fermer la boucle.

Plexicus est l'ASPM natif IA qui scanne, filtre, corrige, penteste et explique — de façon autonome. Développeurs illimités, dépôts illimités, actions IA à usage équitable. Vrai niveau gratuit, €269/mo annuel quand vous êtes prêt.