Description
An object contains a public static field that is not marked final, which might allow it to be modified in unexpected ways.
Public static variables can be read without an accessor and changed without a mutator by any classes in the application.
Potential Impact
Integrity
Modify Application Data
Confidentiality
Read Application Data
Demonstrative Examples
class SomeAppClass {
public:static string appPropertiesConfigFile = "app/properties.config";
...
}public class SomeAppClass {
public static String appPropertiesFile = "app/Application.properties";...
}class SomeAppClass {
public:static const string appPropertiesConfigFile = "app/properties.config";
...
}public class SomeAppClass {
public static final String appPropertiesFile = "app/Application.properties";...
}Mitigations & Prevention
Clearly identify the scope for all critical data elements, including whether they should be regarded as static.
Make any static fields private and constant. A constant field is denoted by the keyword 'const' in C/C++ and ' final' in Java
Detection Methods
- Automated Static Analysis High — 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 sea
Related Weaknesses
Taxonomy Mappings
- CLASP: — Overflow of static internal buffer
- The CERT Oracle Secure Coding Standard for Java (2011): OBJ10-J — Do not use public static nonfinal variables
- Software Fault Patterns: SFP28 — Unexpected access points
Frequently Asked Questions
What is CWE-500?
CWE-500 (Public Static Field Not Marked Final) is a software weakness identified by MITRE's Common Weakness Enumeration. It is classified as a Variant-level weakness. An object contains a public static field that is not marked final, which might allow it to be modified in unexpected ways.
How can CWE-500 be exploited?
Attackers can exploit CWE-500 (Public Static Field Not Marked Final) to modify application data. This weakness is typically introduced during the Implementation phase of software development.
How do I prevent CWE-500?
Key mitigations include: Clearly identify the scope for all critical data elements, including whether they should be regarded as static.
What is the severity of CWE-500?
CWE-500 is classified as a Variant-level weakness (Low-Medium abstraction). Its actual severity depends on the specific context and how the weakness manifests in your application.