CWE-608: Struts: Non-private Field in ActionForm Class
An ActionForm class contains a field that has not been declared private, which can be accessed without using a setter or getter.
Last updated
Overview
CWE-608 (Struts: Non-private Field in ActionForm Class) is a variant-level software weakness catalogued by MITRE in the Common Weakness Enumeration (CWE). It describes a recurring type of mistake that can lead to exploitable security vulnerabilities.
Common consequences
What can happen when CWE-608 is exploited.
Modify Application Data, Read Application Data
Affects: Integrity, Confidentiality
How it happens
When it is introduced
Typically introduced during these phases of the software lifecycle.
Applies to
Languages
How to prevent it
Practical mitigations for CWE-608, grouped by where in the lifecycle they apply.
Make all fields private. Use getter to get the value of the field. Setter should be used only by the framework; setting an action form field from other actions is bad practice and should be avoided.
How to detect it
Automated Static Analysis
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.)
Code examples
Illustrative examples from MITRE showing how the weakness appears in code.
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 a online business site. The user will enter registration data and through the Struts framework the RegistrationForm bean will maintain the user data.
Vulnerable example
public class RegistrationForm extends org.apache.struts.validator.ValidatorForm {Safe example
public class RegistrationForm extends org.apache.struts.validator.ValidatorForm {However, within the RegistrationForm the member variables for the registration form input data are declared public not private. All member variables within a Struts framework ActionForm class must be declared private to prevent the member variables from being modified without using the getter and setter methods. The following example shows the member variables being declared private and getter and setter methods declared for accessing the member variables.
Terminology & mappings
Mapped taxonomies
- Software Fault Patterns: Unexpected access points (SFP28)
Frequently asked questions
Common questions about CWE-608.
- What is CWE-608?
- An ActionForm class contains a field that has not been declared private, which can be accessed without using a setter or getter.
- How do you prevent CWE-608?
- Make all fields private. Use getter to get the value of the field. Setter should be used only by the framework; setting an action form field from other actions is bad practice and should be avoided.
- How is CWE-608 detected?
- Automated Static Analysis: 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.)
- What are the consequences of CWE-608?
- Exploiting CWE-608 can lead to: Modify Application Data, Read Application Data.
References
- MITRE CWE definition (CWE-608) (opens in a new tab)
- CWE-608 vulnerabilities on NVD (opens in a new tab)
- Learn: What is a CWE?
Weakness data is sourced from the MITRE CWE catalog (v4.20). CVE associations are aggregated and kept current by RadicalNotion.AI.
Stay ahead of CWE-608
Get alerted the moment a new CWE-608 vulnerability affects your stack, with AI-written analysis, severity context, and remediation guidance.