Executar análise estática (SAST) na base de código à procura do padrão inseguro no fluxo de dados.
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.
What is CWE-105?
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.
Trajeto do atacante passo a passo
- 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
The validator XML file, validator.xml, provides the validation for the form fields of the RegistrationForm.
- 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.
Vulnerable XML
The validator XML file, validator.xml, provides the validation for the form fields of the RegistrationForm.
<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> 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.
<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> 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.
How to detect CWE-105
Executar testes dinâmicos de segurança de aplicações (DAST) contra o endpoint em execução.
Monitorizar os registos em tempo de execução para traços de exceção invulgares, input malformado ou tentativas de contornar a autorização.
Revisão de código: sinalizar qualquer novo código que trate input desta superfície sem usar os ajudantes validados do framework.
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.
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.
Weaknesses related to CWE-105
Improper Use of Validation Framework
This vulnerability occurs when a software application either fails to use or incorrectly implements a built-in or library-provided input…
Struts: Duplicate Validation Forms
This vulnerability occurs when an application defines multiple Struts validation forms with identical names. The framework then…
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…
Struts: Unvalidated Action Form
In Apache Struts, every Action Form that processes user input must have a corresponding validation form configured. Missing this…
Struts: Validator Turned Off
This vulnerability occurs when an application built with Apache Struts intentionally disables its built-in validation framework. By…
ASP.NET Misconfiguration: Improper Model Validation
This vulnerability occurs when an ASP.NET application either completely bypasses the built-in model validation system or implements it…
ASP.NET Misconfiguration: Not Using Input Validation Framework
This vulnerability occurs when an ASP.NET application fails to implement a structured input validation framework, relying instead on…
Further reading
- MITRE — CWE-105 oficial https://cwe.mitre.org/data/definitions/105.html
- Seven Pernicious Kingdoms: A Taxonomy of Software Security Errors https://samate.nist.gov/SSATTM_Content/papers/Seven%20Pernicious%20Kingdoms%20-%20Taxonomy%20of%20Sw%20Security%20Errors%20-%20Tsipenyuk%20-%20Chess%20-%20McGraw.pdf
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.