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

Export to Word

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().

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.


ThreatScore

Threat Mapped score: 0.0

Industry: Finiancial

Threat priority: Unclassified


Observed Examples (CVEs)

Related Attack Patterns (CAPEC)

N/A


Attack TTPs

N/A

Modes of Introduction

Phase Note
Implementation N/A

Common Consequences

Potential Mitigations

Applicable Platforms


Demonstrative Examples

Intro: 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.

Body: 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.

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) { ActionErrors errors = new ActionErrors(); if (getName() == null || getName().length() < 1) { errors.add("name", new ActionMessage("error.name.required")); } return errors; } // getter and setter methods for private variables ... }

Notes

← Back to CWE list