What it is: Struts: Non-private Field in ActionForm Class (CWE-608) is a vulnerability where fields within an ActionForm class are not declared private, allowing direct access without using setters or getters.
Why it matters: This can lead to unauthorized modification and read of sensitive data stored in the ActionForm fields.
How to fix it: Make all fields within an ActionForm class private, use proper encapsulation techniques such as getters and setters.
TL;DR: Struts: Non-private Field in ActionForm Class (CWE-608) is a vulnerability where fields within an ActionForm class are not declared private, allowing direct access without using setters or getters. This can lead to unauthorized modification and read of sensitive data stored in the ActionForm fields. To fix it, make all fields within an ActionForm class private and use proper encapsulation techniques such as getters and setters.
| Field | Value |
|---|---|
| CWE ID | CWE-608 |
| OWASP Category | Not directly mapped |
| CAPEC | None known |
| Typical Severity | Medium |
| Affected Technologies | Apache Struts |
| Detection Difficulty | Moderate |
| Last Updated | 2026-07-29 |
What is Struts: Non-private Field in ActionForm Class?
Struts: Non-private Field in ActionForm Class (CWE-608) is a type of vulnerability that occurs when fields within an ActionForm class are not declared private, allowing them to be accessed directly without using setter or getter methods. As defined by the MITRE Corporation under CWE-608.
Quick Summary
Struts: Non-private Field in ActionForm Class allows unauthorized access and modification of sensitive data stored in ActionForm classes. This vulnerability can lead to serious security breaches if not addressed promptly. Jump to: Overview · How It Works · Business Impact · Attack Scenario · Detection · Fixes
Jump to: Quick Summary · Struts: Non-private Field in ActionForm Class Overview · How Struts: Non-private Field in ActionForm Class Works · Business Impact of Struts: Non-private Field in ActionForm Class · Struts: Non-private Field in ActionForm Class Attack Scenario · How to Detect Struts: Non-private Field in ActionForm Class · How to Fix Struts: Non-private Field in ActionForm Class · Framework-Specific Fixes for Struts: Non-private Field in ActionForm Class · How to Ask AI to Check Your Code for Struts: Non-private Field in ActionForm Class · Struts: Non-private Field in ActionForm Class Best Practices Checklist · Struts: Non-private Field in ActionForm Class FAQ · Vulnerabilities Related to Struts: Non-private Field in ActionForm Class · References · Scan Your Own Site
Struts: Non-private Field in ActionForm Class Overview
What
Struts: Non-private Field in ActionForm Class is a vulnerability where fields within an ActionForm class are not declared private, allowing direct access without using setters or getters.
Why it matters
This can lead to unauthorized modification and read of sensitive data stored in the ActionForm fields. It undermines proper encapsulation practices and exposes application data to potential exploitation.
Where it occurs
In Apache Struts applications where ActionForm classes are used but do not adhere to best practices for field access control.
Who is affected
Developers using Apache Struts who have ActionForm classes with non-private fields.
Who is NOT affected
Applications that properly encapsulate their data and ensure all fields in ActionForm classes are declared private with appropriate getter and setter methods.
How Struts: Non-private Field in ActionForm Class Works
Root Cause
Fields within an ActionForm class are not declared as private, allowing direct access to sensitive information without proper encapsulation techniques such as getters and setters.
Attack Flow
- An attacker identifies a field within an ActionForm class that is not marked private.
- The attacker uses this direct access to read or modify the data stored in the field.
- Unauthorized actions are performed on the application’s sensitive data.
Prerequisites to Exploit
- Fields within an ActionForm class must be declared non-private and accessible without proper encapsulation techniques.
Vulnerable Code
public class UserActionForm {
public String username;
}
This code demonstrates a field username that is not marked private, allowing direct access to the data stored in it.
Secure Code
public class UserActionForm {
private String username;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
}
This secure code ensures that all fields within an ActionForm class are declared as private and uses getter and setter methods to control access.
Business Impact of Struts: Non-private Field in ActionForm Class
Confidentiality
- Sensitive data stored in ActionForm classes can be read by unauthorized users.
- Example: An attacker reads the
usernamefield directly from an ActionForm class without using proper encapsulation techniques.
- Example: An attacker reads the
Integrity
- Unauthorized modification of sensitive data within ActionForm classes is possible.
- Example: An attacker modifies the value of a non-private field in an ActionForm class, leading to incorrect application behavior.
Availability
- Potential disruption of service if critical fields are tampered with.
- Example: An attacker alters the value of a non-private field used for authentication purposes, causing the system to malfunction.
Business consequences include:
- Financial losses due to unauthorized access and data breaches.
- Compliance issues arising from failing to protect sensitive information.
- Damage to reputation from publicized security incidents.
Struts: Non-private Field in ActionForm Class Attack Scenario
- An attacker identifies an ActionForm class with a non-private field, such as
username. - The attacker uses direct access to read the value of this field without using proper encapsulation techniques.
- Unauthorized actions are performed on the application’s sensitive data, leading to potential security breaches.
How to Detect Struts: Non-private Field in ActionForm Class
Manual Testing
- Review all ActionForm classes for fields that are not marked private.
- Ensure that getter and setter methods are implemented for each field.
Automated Scanners (SAST / DAST)
Static analysis can identify non-private fields within ActionForm classes. Dynamic testing is necessary to confirm if these fields are actually being accessed without proper encapsulation techniques.
PenScan Detection
PenScan’s scanner engines such as ZAP, Nuclei, Wapiti, Nikto, SSLyze, Dalfox, and Nmap can detect non-private fields within ActionForm classes during automated scans.
False Positive Guidance
A false positive occurs if a field is marked private but still appears to be accessible due to other configuration issues or coding practices. Ensure that the field is indeed declared as private with proper getter and setter methods in place.
How to Fix Struts: Non-private Field in ActionForm Class
- Make all fields within an ActionForm class private.
- Implement appropriate getter and setter methods for each field to control access.
- Use encapsulation techniques to prevent direct access to sensitive data stored in the ActionForm classes.
Framework-Specific Fixes for Struts: Non-private Field in ActionForm Class
public class UserActionForm {
private String username;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
}
This example demonstrates the proper encapsulation of a field within an ActionForm class in Java.
How to Ask AI to Check Your Code for Struts: Non-private Field in ActionForm Class
Review the following [language] code block for potential CWE-608 Struts: Non-private Field in ActionForm Class vulnerabilities and rewrite it using proper encapsulation techniques such as getters and setters:
Struts: Non-private Field in ActionForm Class Best Practices Checklist
✅ Ensure all fields within an ActionForm class are declared as private. ✅ Implement getter methods to retrieve the value of each field. ✅ Implement setter methods to set the value of each field. ✅ Use encapsulation techniques to prevent direct access to sensitive data stored in the ActionForm classes. ✅ Review and test your code regularly for any potential vulnerabilities.
Struts: Non-private Field in ActionForm Class FAQ
How does the Struts: Non-private Field in ActionForm Class vulnerability work?
The vulnerability occurs when fields within an ActionForm class are not declared private, allowing them to be accessed directly without using setters or getters.
Why is it important to fix Struts: Non-private Field in ActionForm Class vulnerabilities?
Fixing this issue prevents unauthorized access and modification of sensitive data stored in the ActionForm fields.
Can you provide an example of vulnerable code for Struts: Non-private Field in ActionForm Class?
A field declared as public within an ActionForm class, such as public String username;, allows direct access without proper encapsulation.
How can I detect Struts: Non-private Field in ActionForm Class vulnerabilities manually?
Review the ActionForm classes for fields that are not marked private and ensure they use setter methods to control access.
What is a framework-specific fix for Struts: Non-private Field in ActionForm Class?
In Apache Struts, make all fields within ActionForm classes private and implement appropriate getter and setter methods.
How can I prevent the Struts: Non-private Field in ActionForm Class vulnerability from occurring?
Ensure that all fields in ActionForm classes are declared as private and use proper encapsulation techniques such as getters and setters.
What is the business impact of a Struts: Non-private Field in ActionForm Class vulnerability?
Unauthorized access to sensitive data can lead to financial losses, compliance issues, and damage to reputation.
Vulnerabilities Related to Struts: Non-private Field in ActionForm Class
| CWE | Name | Relationship |
|---|---|---|
| CWE-668 | Exposure of Resource to Wrong Sphere (ChildOf) |
References
Scan Your Own Site
Manual code review catches what you know to look for. An automated scan catches what you didn’t. Scan your own website using PenScan to find Struts: Non-private Field in ActionForm Class and other risks before an attacker does.