CWE-105 Variante Brouillon

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 unverified user input.

Définition

What is CWE-105?

This vulnerability occurs when a Struts application form contains an input field that lacks a corresponding validator, leaving it open to unverified user input.
Leaving even one form field without validation creates a direct opening for attackers. They can exploit this oversight to inject malicious data, bypass security checks, or manipulate application logic, potentially leading to data breaches, unauthorized access, or system compromise. While Java applications themselves are often protected from low-level memory issues, the risk escalates if the application interacts with native code or external systems. An attacker could use this unvalidated input as an entry point to trigger buffer overflows or other critical vulnerabilities in those connected components, turning a simple input oversight into a severe chained attack.
Impact réel

Real-world CVEs caused by CWE-105

Aucune référence CVE publique n'est liée à ce CWE dans le catalogue MITRE pour le moment.

Comment les attaquants l'exploitent

Parcours de l'attaquant étape par étape

  1. 1

    In the following example the Java class RegistrationForm is a Struts framework ActionForm Bean that will maintain user input data from a registration webpage for an online business site. The user will enter registration data and, through the Struts framework, the RegistrationForm bean will maintain the user data in the form fields using the private member variables. The RegistrationForm class uses the Struts validation capability by extending the ValidatorForm class and including the validation for the form fields within the validator XML file, validator.xml.

  2. 2

    The validator XML file, validator.xml, provides the validation for the form fields of the RegistrationForm.

  3. 3

    However, in the previous example the validator XML file, validator.xml, does not provide validators for all of the form fields in the RegistrationForm. Validator forms are only provided for the first five of the seven form fields. The validator XML file should contain validator forms for all of the form fields for a Struts ActionForm bean. The following validator.xml file for the RegistrationForm class contains validator forms for all of the form fields.

Exemple de code vulnérable

Vulnerable XML

The validator XML file, validator.xml, provides the validation for the form fields of the RegistrationForm.

Vulnérable XML
<form-validation>
  	<formset>
  		<form name="RegistrationForm">
  			<field property="name" depends="required">
  				<arg position="0" key="prompt.name"/>
  			</field>
  			<field property="address" depends="required">
  				<arg position="0" key="prompt.address"/>
  			</field>
  			<field property="city" depends="required">
  				<arg position="0" key="prompt.city"/>
  			</field>
  			<field property="state" depends="required,mask">
  				<arg position="0" key="prompt.state"/>
  				<var>
  					<var-name>mask</var-name>
  					<var-value>[a-zA-Z]{2}</var-value>
  				</var>
  			</field>
  			<field property="zipcode" depends="required,mask">
  				<arg position="0" key="prompt.zipcode"/>
  				<var>
  					<var-name>mask</var-name>
  					<var-value>\d{5}</var-value>
  				</var>
  			</field>
  		</form>
  	</formset>
  </form-validation>
Exemple de code sécurisé

Secure XML

However, in the previous example the validator XML file, validator.xml, does not provide validators for all of the form fields in the RegistrationForm. Validator forms are only provided for the first five of the seven form fields. The validator XML file should contain validator forms for all of the form fields for a Struts ActionForm bean. The following validator.xml file for the RegistrationForm class contains validator forms for all of the form fields.

Sécurisé XML
<form-validation>
  	<formset>
  		<form name="RegistrationForm">
  			<field property="name" depends="required">
  				<arg position="0" key="prompt.name"/>
  			</field>
  			<field property="address" depends="required">
  				<arg position="0" key="prompt.address"/>
  			</field>
  			<field property="city" depends="required">
  				<arg position="0" key="prompt.city"/>
  			</field>
  			<field property="state" depends="required,mask">
  				<arg position="0" key="prompt.state"/>
  				<var>
  					<var-name>mask</var-name>
  					<var-value>[a-zA-Z]{2}</var-value>
  				</var>
  			</field>
  			<field property="zipcode" depends="required,mask">
  				<arg position="0" key="prompt.zipcode"/>
  				<var>
  					<var-name>mask</var-name>
  					<var-value>\d{5}</var-value>
  				</var>
  			</field>
  			<field property="phone" depends="required,mask">
  				<arg position="0" key="prompt.phone"/>
  				<var>
  					<var-name>mask</var-name>
  					<var-value>^([0-9]{3})(-)([0-9]{4}|[0-9]{4})$</var-value>
  				</var>
  			</field>
  			<field property="email" depends="required,email">
  				<arg position="0" key="prompt.email"/>
  			</field>
  		</form>
  	</formset>
  </form-validation>
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-105

  • Implementation Validate all form fields. If a field is unused, it is still important to constrain it so that it is empty or undefined.
Signaux de détection

How to detect CWE-105

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-105 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-105 ?

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

Quelle est la gravité de CWE-105 ?

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-105 ?

MITRE lists the following affected platforms: Java.

Comment puis-je prévenir CWE-105 ?

Validate all form fields. If a field is unused, it is still important to constrain it so that it is empty or undefined.

Comment Plexicus détecte et corrige CWE-105 ?

Le moteur SAST de Plexicus reconnaît la signature de flux de données de CWE-105 à 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-105 ?

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

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.