{"@ID": "105", "@Name": "Struts: Form Field Without Validator", "@Abstraction": "Variant", "@Structure": "Simple", "@Status": "Draft", "Description": "The product has a form field that is not validated by a corresponding validation form, which can introduce other weaknesses related to insufficient input validation.", "Related_Weaknesses": {"Related_Weakness": [{"@Nature": "ChildOf", "@CWE_ID": "1173", "@View_ID": "1000", "@Ordinal": "Primary"}, {"@Nature": "ChildOf", "@CWE_ID": "20", "@View_ID": "700", "@Ordinal": "Primary"}]}, "Weakness_Ordinalities": {"Weakness_Ordinality": {"Ordinality": "Primary"}}, "Applicable_Platforms": {"Language": {"@Name": "Java", "@Prevalence": "Undetermined"}}, "Modes_Of_Introduction": {"Introduction": {"Phase": "Implementation", "Note": "Some products use the same ActionForm for more than one purpose. In situations like this, some fields may go unused under some action mappings."}}, "Common_Consequences": {"Consequence": [{"Scope": "Integrity", "Impact": "Unexpected State", "Note": "Omitting validation for even a single input field may give attackers the leeway they need to compromise the product. Although J2EE applications are not generally susceptible to memory corruption attacks, if a J2EE application interfaces with native code that does not perform array bounds checking, an attacker may be able to use an input validation mistake in the J2EE application to launch a buffer overflow attack."}, {"Scope": "Integrity", "Impact": "Bypass Protection Mechanism", "Note": "If unused fields are not validated, shared business logic in an action may allow attackers to bypass the validation checks that are performed for other uses of the form."}]}, "Detection_Methods": {"Detection_Method": {"@Detection_Method_ID": "DM-14", "Method": "Automated Static Analysis", "Description": "Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect \"sources\" (origins of input) with \"sinks\" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)"}}, "Potential_Mitigations": {"Mitigation": {"Phase": "Implementation", "Description": "Validate all form fields. If a field is unused, it is still important to constrain it so that it is empty or undefined."}}, "Demonstrative_Examples": {"Demonstrative_Example": {"Intro_Text": "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.", "Example_Code": [{"@Nature": "Result", "xhtml:div": {"xhtml:div": {"@style": "margin-left:1em;", "xhtml:br": [null, null, null, null, null, null, null, null, null, null, null, null, null, null], "xhtml:i": ["// private variables for registration form", "// getter and setter methods for private variables"], "xhtml:div": {"@style": "margin-left:1em;", "#text": "super();"}, "#text": "private String name;private String address;private String city;private String state;private String zipcode;private String phone;private String email;\n                        public RegistrationForm() {}\n                        \n                        \n                        ..."}, "#text": "public class RegistrationForm extends org.apache.struts.validator.ValidatorForm {}"}, "#text_blocks": ["public class RegistrationForm extends org.apache.struts.validator.ValidatorForm {", "// private variables for registration form", "private String name;", "private String address;", "private String city;", "private String state;", "private String zipcode;", "private String phone;", "private String email;", "public RegistrationForm() {", "super();", "}", "// getter and setter methods for private variables", "...", "}"]}, {"@Nature": "Bad", "@Language": "XML", "xhtml:div": {"xhtml:div": {"@style": "margin-left:1em;", "xhtml:div": {"@style": "margin-left:1em;", "xhtml:div": {"@style": "margin-left:1em;", "xhtml:div": [{"@style": "margin-left:1em;", "#text": "<arg position=\"0\" key=\"prompt.name\"/>"}, {"@style": "margin-left:1em;", "#text": "<arg position=\"0\" key=\"prompt.address\"/>"}, {"@style": "margin-left:1em;", "#text": "<arg position=\"0\" key=\"prompt.city\"/>"}, {"@style": "margin-left:1em;", "xhtml:br": null, "xhtml:div": {"@style": "margin-left:1em;", "xhtml:br": null, "#text": "<var-name>mask</var-name><var-value>[a-zA-Z]{2}</var-value>"}, "#text": "<arg position=\"0\" key=\"prompt.state\"/><var></var>"}, {"@style": "margin-left:1em;", "xhtml:br": null, "xhtml:div": {"@style": "margin-left:1em;", "xhtml:br": null, "#text": "<var-name>mask</var-name><var-value>\\d{5}</var-value>"}, "#text": "<arg position=\"0\" key=\"prompt.zipcode\"/><var></var>"}], "xhtml:br": [null, null, null, null], "#text": "<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>"}, "#text": "<form name=\"RegistrationForm\"></form>"}, "#text": "<formset></formset>"}, "#text": "<form-validation></form-validation>"}, "#text_blocks": ["<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>"]}, {"@Nature": "Good", "@Language": "XML", "xhtml:div": {"xhtml:div": {"@style": "margin-left:1em;", "xhtml:div": {"@style": "margin-left:1em;", "xhtml:div": {"@style": "margin-left:1em;", "xhtml:div": [{"@style": "margin-left:1em;", "#text": "<arg position=\"0\" key=\"prompt.name\"/>"}, {"@style": "margin-left:1em;", "#text": "<arg position=\"0\" key=\"prompt.address\"/>"}, {"@style": "margin-left:1em;", "#text": "<arg position=\"0\" key=\"prompt.city\"/>"}, {"@style": "margin-left:1em;", "xhtml:br": null, "xhtml:div": {"@style": "margin-left:1em;", "xhtml:br": null, "#text": "<var-name>mask</var-name><var-value>[a-zA-Z]{2}</var-value>"}, "#text": "<arg position=\"0\" key=\"prompt.state\"/><var></var>"}, {"@style": "margin-left:1em;", "xhtml:br": null, "xhtml:div": {"@style": "margin-left:1em;", "xhtml:br": null, "#text": "<var-name>mask</var-name><var-value>\\d{5}</var-value>"}, "#text": "<arg position=\"0\" key=\"prompt.zipcode\"/><var></var>"}, {"@style": "margin-left:1em;", "xhtml:br": null, "xhtml:div": {"@style": "margin-left:1em;", "xhtml:br": null, "#text": "<var-name>mask</var-name><var-value>^([0-9]{3})(-)([0-9]{4}|[0-9]{4})$</var-value>"}, "#text": "<arg position=\"0\" key=\"prompt.phone\"/><var></var>"}, {"@style": "margin-left:1em;", "#text": "<arg position=\"0\" key=\"prompt.email\"/>"}], "xhtml:br": [null, null, null, null, null, null], "#text": "<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>"}, "#text": "<form name=\"RegistrationForm\"></form>"}, "#text": "<formset></formset>"}, "#text": "<form-validation></form-validation>"}, "#text_blocks": ["<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>"]}], "Body_Text": ["The validator XML file, validator.xml, provides the validation for the form fields of the RegistrationForm.", "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."]}}, "Taxonomy_Mappings": {"Taxonomy_Mapping": [{"@Taxonomy_Name": "7 Pernicious Kingdoms", "Entry_Name": "Struts: Form Field Without Validator"}, {"@Taxonomy_Name": "Software Fault Patterns", "Entry_ID": "SFP24", "Entry_Name": "Tainted input to command"}]}, "References": {"Reference": {"@External_Reference_ID": "REF-6"}}, "Mapping_Notes": {"Usage": "Allowed", "Rationale": "This CWE entry is at the Variant level of abstraction, which is a preferred level of abstraction for mapping to the root causes of vulnerabilities.", "Comments": "Carefully read both the name and description to ensure that this mapping is an appropriate fit. Do not try to 'force' a mapping to a lower-level Base/Variant simply to comply with this preferred level of abstraction.", "Reasons": {"Reason": {"@Type": "Acceptable-Use"}}}, "Content_History": {"Submission": {"Submission_Name": "7 Pernicious Kingdoms", "Submission_Date": "2006-07-19", "Submission_Version": "Draft 3", "Submission_ReleaseDate": "2006-07-19"}, "Modification": [{"Modification_Name": "Eric Dalci", "Modification_Organization": "Cigital", "Modification_Date": "2008-07-01", "Modification_Version": "1.0", "Modification_ReleaseDate": "2008-09-09", "Modification_Comment": "updated Time_of_Introduction"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2008-09-08", "Modification_Version": "1.0", "Modification_ReleaseDate": "2008-09-09", "Modification_Comment": "updated Relationships, Other_Notes, Taxonomy_Mappings, Weakness_Ordinalities"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2010-06-21", "Modification_Version": "1.9", "Modification_ReleaseDate": "2010-06-21", "Modification_Comment": "updated Demonstrative_Examples"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2011-06-01", "Modification_Version": "1.13", "Modification_ReleaseDate": "2011-06-01", "Modification_Comment": "updated Common_Consequences"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2011-06-27", "Modification_Version": "2.0", "Modification_ReleaseDate": "2011-06-27", "Modification_Comment": "updated Common_Consequences"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2012-05-11", "Modification_Version": "2.2", "Modification_ReleaseDate": "2012-05-15", "Modification_Comment": "updated Relationships"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2012-10-30", "Modification_Version": "2.3", "Modification_ReleaseDate": "2012-10-30", "Modification_Comment": "updated Potential_Mitigations"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2014-06-23", "Modification_Version": "2.7", "Modification_ReleaseDate": "2014-06-23", "Modification_Comment": "updated Common_Consequences, Description, Modes_of_Introduction, Other_Notes"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2014-07-30", "Modification_Version": "2.8", "Modification_ReleaseDate": "2014-07-31", "Modification_Comment": "updated Relationships, Taxonomy_Mappings"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2017-11-08", "Modification_Version": "3.0", "Modification_ReleaseDate": "2017-11-08", "Modification_Comment": "updated Causal_Nature, Relationships"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2019-01-03", "Modification_Version": "3.2", "Modification_ReleaseDate": "2019-01-03", "Modification_Comment": "updated Relationships"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2020-02-24", "Modification_Version": "4.0", "Modification_ReleaseDate": "2020-02-24", "Modification_Comment": "updated References, Relationships"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2021-07-20", "Modification_Version": "4.5", "Modification_ReleaseDate": "2021-07-20", "Modification_Comment": "updated Potential_Mitigations"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2023-01-31", "Modification_Version": "4.10", "Modification_ReleaseDate": "2023-01-31", "Modification_Comment": "updated Description, Modes_of_Introduction"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2023-04-27", "Modification_Version": "4.11", "Modification_ReleaseDate": "2023-04-27", "Modification_Comment": "updated Relationships"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2023-06-29", "Modification_Version": "4.12", "Modification_ReleaseDate": "2023-06-29", "Modification_Comment": "updated Mapping_Notes"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2026-10-28", "Modification_Version": "5.0", "Modification_ReleaseDate": "2026-10-28", "Modification_Comment": "updated Common_Consequences, Description, Detection_Factors, References"}]}, "entry_type": "Weakness"}
