CWE-105 Variante Rascunho

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.

Definição

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.
Impacto no mundo real

Real-world CVEs caused by CWE-105

Ainda não há referências CVE públicas associadas a este CWE no catálogo da MITRE.

Como os atacantes a exploram

Trajeto do atacante passo a passo

  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.

Exemplo de código vulnerável

Vulnerable XML

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

Vulnerável 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>
Exemplo de código seguro

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.

Seguro 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.
Lista de verificação de prevenção

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.
Sinais de deteção

How to detect CWE-105

SAST High

Executar análise estática (SAST) na base de código à procura do padrão inseguro no fluxo de dados.

DAST Moderate

Executar testes dinâmicos de segurança de aplicações (DAST) contra o endpoint em execução.

Runtime Moderate

Monitorizar os registos em tempo de execução para traços de exceção invulgares, input malformado ou tentativas de contornar a autorização.

Code review Moderate

Revisão de código: sinalizar qualquer novo código que trate input desta superfície sem usar os ajudantes validados do framework.

Correção automática do Plexicus

O Plexicus deteta automaticamente o CWE-105 e abre um PR de correção em menos de 60 segundos.

O Codex Remedium analisa cada commit, identifica esta fraqueza exata e entrega um pull request pronto para revisão com o patch. Sem tickets. Sem transferências.

Perguntas frequentes

Frequently asked questions

O que é o 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.

Qual a gravidade do CWE-105?

A MITRE não publicou uma classificação de probabilidade de exploração para esta fraqueza. Trate-a como impacto médio até o seu modelo de ameaças provar o contrário.

Que linguagens ou plataformas são afetadas pelo CWE-105?

MITRE lists the following affected platforms: Java.

Como posso prevenir o 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.

Como é que o Plexicus deteta e corrige o CWE-105?

O motor SAST do Plexicus correlaciona a assinatura de fluxo de dados do CWE-105 em cada commit. Quando é encontrada uma correspondência, o nosso agente Codex Remedium abre um PR de correção com o código corrigido, testes e um resumo de uma linha para o revisor.

Onde posso saber mais sobre o CWE-105?

A MITRE publica a definição canónica em https://cwe.mitre.org/data/definitions/105.html. Pode também consultar a documentação da OWASP e do NIST para orientações adjacentes.

Pronto quando você estiver

Pare de pagar por desenvolvedor.
Comece a fechar o ciclo.

O Plexicus é o ASPM nativo de IA que verifica, filtra, corrige, pentesta e explica — de forma autónoma. Programadores ilimitados, repos ilimitados, ações de IA de utilização justa. Nível gratuito real, €269/mo anual quando estiver pronto.