CWE-106 Variante Rascunho

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 validation plugin like the Struts Validator. Skipping this framework…

Definição

What is CWE-106?

This weakness occurs when a Java application, particularly one using the Struts framework, does not implement a structured input validation plugin like the Struts Validator. Skipping this framework forces developers to write custom validation logic, which is often error-prone and increases the risk of security flaws from improperly handled user input.
Without a dedicated validation framework, your application becomes vulnerable to common web attacks. Unchecked user input is a primary entry point for cross-site scripting (XSS), SQL injection, and unauthorized command execution, as attackers can inject malicious code or manipulate application logic. While Java environments typically avoid memory corruption issues, the risk extends to integrated native code. If your J2EE application passes unvalidated data to native libraries or components that lack proper bounds checking, a simple input validation oversight can escalate into a severe buffer overflow attack, compromising the entire system.
Impacto no mundo real

Real-world CVEs caused by CWE-106

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 Java example the 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.

  2. 2

    However, the RegistrationForm class extends the Struts ActionForm class which does use the Struts validator plug-in to provide validator capabilities. In the following example, the RegistrationForm Java class extends the ValidatorForm and Struts configuration XML file, struts-config.xml, instructs the application to use the Struts validator plug-in.

  3. 3

    The plug-in tag of the Struts configuration XML file includes the name of the validator plug-in to be used and includes a set-property tag to instruct the application to use the file, validator-rules.xml, for default validation rules and the file, validation.XML, for custom validation.

Exemplo de código vulnerável

Vulnerable Java

In the following Java example the 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.

Vulnerável Java
public class RegistrationForm extends org.apache.struts.action.ActionForm {
```
// private variables for registration form* 
  	private String name;
  	private String email;
  	...
  	
  	public RegistrationForm() {
  	```
  		super();
  	}
```
// getter and setter methods for private variables* 
  	...
  	}
Exemplo de código seguro

Secure Java

However, the RegistrationForm class extends the Struts ActionForm class which does use the Struts validator plug-in to provide validator capabilities. In the following example, the RegistrationForm Java class extends the ValidatorForm and Struts configuration XML file, struts-config.xml, instructs the application to use the Struts validator plug-in.

Seguro Java
public class RegistrationForm extends org.apache.struts.validator.ValidatorForm {
```
// private variables for registration form* 
  	private String name;
  	private String email;
  	...
  	
  	public RegistrationForm() {
  	```
  		super();
  	}
  	public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {...}
```
// getter and setter methods for private variables* 
  	...
  	}
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-106

  • Architecture and Design Use an input validation framework such as Struts.
  • Architecture and Design Use an input validation framework such as Struts.
  • Implementation Use the Struts Validator to validate all program input before it is processed by the application. Ensure that there are no holes in the configuration of the Struts Validator. Example uses of the validator include checking to ensure that: - Phone number fields contain only valid characters in phone numbers - Boolean values are only "T" or "F" - Free-form strings are of a reasonable length and composition
  • Implementation Use the Struts Validator to validate all program input before it is processed by the application. Ensure that there are no holes in the configuration of the Struts Validator. Example uses of the validator include checking to ensure that: - Phone number fields contain only valid characters in phone numbers - Boolean values are only "T" or "F" - Free-form strings are of a reasonable length and composition
Sinais de deteção

How to detect CWE-106

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

This weakness occurs when a Java application, particularly one using the Struts framework, does not implement a structured input validation plugin like the Struts Validator. Skipping this framework forces developers to write custom validation logic, which is often error-prone and increases the risk of security flaws from improperly handled user input.

Qual a gravidade do CWE-106?

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

MITRE lists the following affected platforms: Java.

Como posso prevenir o CWE-106?

Use an input validation framework such as Struts. Use an input validation framework such as Struts.

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

O motor SAST do Plexicus correlaciona a assinatura de fluxo de dados do CWE-106 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-106?

A MITRE publica a definição canónica em https://cwe.mitre.org/data/definitions/106.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.