CWE-107: Struts: Unused Validation Form

Description

An unused validation form indicates that validation logic is not up-to-date.

Submission Date :

July 19, 2006, midnight

Modification Date :

2023-06-29 00:00:00+00:00

Organization :

MITRE
Extended Description

It is easy for developers to forget to update validation logic when they remove or rename action form mappings. One indication that validation logic is not being properly maintained is the presence of an unused validation form.

Example Vulnerable Codes

Example - 1

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



// // private variables for registration form// 
// // no longer using the phone form field// 
// // private String phone;// 
super();
// // getter and setter methods for private variables// 
private String name;private String address;private String city;private String state;private String zipcode;private String email;public RegistrationForm() {}...public class RegistrationForm extends org.apache.struts.validator.ValidatorForm {}
<arg position="0" key="prompt.name"/>
<arg position="0" key="prompt.address"/>
<arg position="0" key="prompt.city"/>


<var-name>mask</var-name><var-value>[a-zA-Z]{2}</var-value><arg position="0" key="prompt.state"/><var></var>


<var-name>mask</var-name><var-value>\d{5}</var-value><arg position="0" key="prompt.zipcode"/><var></var>


<var-name>mask</var-name><var-value>^([0-9]{3})(-)([0-9]{4}|[0-9]{4})$</var-value><arg position="0" key="prompt.phone"/><var></var>
<arg position="0" key="prompt.email"/><field property="name" depends="required"></field><field property="address" depends="required"></field><field property="city" depends="required"></field><field property="state" depends="required,mask"></field><field property="zipcode" depends="required,mask"></field><field property="phone" depends="required,mask"></field><field property="email" depends="required,email"></field><form name="RegistrationForm"></form><formset></formset><form-validation></form-validation>

However, the validator XML file, validator.xml, for the RegistrationForm class includes the validation form for the user input form field "phone" that is no longer used by the input form and the RegistrationForm class. Any validation forms that are no longer required should be removed from the validator XML file, validator.xml.

The existence of unused forms may be an indication to attackers that this code is out of date or poorly maintained.

Related Weaknesses

This table shows the weaknesses and high level categories that are related to this weakness. These relationships are defined to give an overview of the different insight to similar items that may exist at higher and lower levels of abstraction.

Visit http://cwe.mitre.org/ for more details.

© cvefeed.io
Latest DB Update: Dec. 23, 2024 5:10