CWE-103: Struts: Incomplete validate() Method Definition

Description

The product has a validator form that either does not define a validate() method, or defines a validate() method but does not call super.validate().

Submission Date :

July 19, 2006, midnight

Modification Date :

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

Organization :

MITRE
Extended Description

If the code does not call super.validate(), the Validation Framework cannot check the contents of the form against a validation form. In other words, the validation framework will be disabled for the given form.

Example Vulnerable Codes

Example - 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 the RegistrationForm bean in the Struts framework will maintain the user data. Tthe RegistrationForm class implements the validate method to validate the user input entered into the form.



super();

errors.add("name", new ActionMessage("error.name.required"));
ActionErrors errors = new ActionErrors();if (getName() == null || getName().length() < 1) {}return errors;// private variables for registration formprivate String name;private String email;...public RegistrationForm() {}public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {}

// getter and setter methods for private variables...
public class RegistrationForm extends org.apache.struts.validator.ValidatorForm {}

Although the validate method is implemented in this example the method does not call the validate method of the ValidatorForm parent class with a call super.validate(). Without the call to the parent validator class only the custom validation will be performed and the default validation will not be performed. The following example shows that the validate method of the ValidatorForm class is called within the implementation of the validate method.



super();

errors = new ActionErrors();ActionErrors errors = super.validate(mapping, request);if (errors == null) {}
errors.add("name", new ActionMessage("error.name.required"));
// private variables for registration formprivate String name;private String email;...public RegistrationForm() {}public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {if (getName() == null || getName().length() < 1) {}return errors;

// getter and setter methods for private variables...public class RegistrationForm extends org.apache.struts.validator.ValidatorForm {}}

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: Nov. 21, 2024 12:54