Avoid Duplicate Struts validation forms with the same name | CAST Appmarq

Avoid Duplicate Struts validation forms with the same name


Rule Definition
If two validation forms have the same name, the Struts Validator arbitrarily chooses one of the forms to use for input validation and discards the other. This decision might not correspond to the programmer's expectations, possibly leading to resultant weaknesses. Moreover, it indicates that the validation logic is not up-to-date, and can indicate that other, more subtle validation errors are present.

Remediation
Remove the duplicate struts validation form.

Violation Code Sample
Two validation forms with the same name.


<form-validation>
    <formset>
        <form name="LoginForm">
            <field property="userName" depends="required">
                <arg key="LoginForm.userName"/>
            </field>
            <field property="password" depends="required,minlength">
                <arg0 key="LoginForm.password"/>
                <arg1 key="${var:minlength}" name="minlength" resource="false"/><br>
                <var>
                <var-name>minlength</var-name>
                <var-value>6</var-value>
                </var>
            </field>
        </form>
       <form name="LoginForm"> // Violation 
            <field property="userPhone" depends="required">
                <arg key="LoginForm.userPhone"/>
            </field>
            ......
        </form>
    </formset>
</form-validation>
Fixed Code Sample
<form-validation>
    <formset>
        <form name="LoginForm1">
            <field property="userName" depends="required">
                <arg key="LoginForm1.userName"/>
            </field>
            <field property="password" depends="required,minlength">
                <arg0 key="LoginForm1.password"/>
                <arg1 key="${var:minlength}" name="minlength" resource="false"/><br>
                <var>
                <var-name>minlength</var-name>
                <var-value>6</var-value>
                </var>
            </field>
        </form>
       <form name="LoginForm2"> // FIXED
            <field property="userPhone" depends="required">
                <arg key="LoginForm2.userPhone"/>
            </field>
            ......
        </form>
    </formset>
</form-validation>

Reference
https://cwe.mitre.org/data/definitions/102.html https://www.owasp.org/index.php/Improper_Data_Validation#Struts:_Duplicate_Validation_Forms https://www.owasp.org/index.php/Top_10-2017_A6-Security_Misconfiguration

Related Technologies

Health Factor

  Total Quality Index


Technical Criterion
PCI-DSS4-Requirement-2.2.6 - System security parameters are configured to prevent misuse

About CAST Appmarq

CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.

Benchmark Statistics

Global Compliance

nan%

Total Violations
0
Total Opportunities
0
Average Violations / App.
nan
The compliance score represents 1 minus the ratio between the number of times a rule has been violated compared to the number of opportunities in a set of applications that the rule could have been violated.

Industry Insights

Financial Services

100.00%

Insurance

100.00%

Select from drop-down

100.00%