CWE-500: Public Static Field Not Marked Final
View customized information:
For users who are interested in more notional aspects of a weakness. Example: educators, technical writers, and project/program managers.
For users who are concerned with the practical application and details about the nature of a weakness and how to prevent it from happening. Example: tool developers, security researchers, pen-testers, incident response analysts.
For users who are mapping an issue to CWE/CAPEC IDs, i.e., finding the most appropriate CWE for a specific issue (e.g., a CVE record). Example: tool developers, security researchers.
For users who wish to see all available information for the CWE/CAPEC entry.
For users who want to customize what details are displayed.
×
Edit Custom FilterAn 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.
![]()
![]() ![]()
![]()
![]() Languages C++ (Undetermined Prevalence) Java (Undetermined Prevalence) Example 1 The following examples use of a public static String variable to contain the name of a property/configuration file for the application. (bad code)
Example Language: C++
class SomeAppClass {
public: static string appPropertiesConfigFile = "app/properties.config";
... (bad code)
Example Language: Java
public class SomeAppClass {
public static String appPropertiesFile = "app/Application.properties"; ... Having a public static variable that is not marked final (constant) may allow the variable to the altered in a way not intended by the application. In this example the String variable can be modified to indicate a different on nonexistent properties file which could cause the application to crash or caused unexpected behavior. (good code)
Example Language: C++
class SomeAppClass {
public: static const string appPropertiesConfigFile = "app/properties.config";
... (good code)
Example Language: Java
public class SomeAppClass {
public static final String appPropertiesFile = "app/Application.properties"; ...
![]()
More information is available — Please edit the custom filter or select a different filter. |
Use of the Common Weakness Enumeration (CWE™) and the associated references from this website are subject to the Terms of Use. CWE is sponsored by the U.S. Department of Homeland Security (DHS) Cybersecurity and Infrastructure Security Agency (CISA) and managed by the Homeland Security Systems Engineering and Development Institute (HSSEDI) which is operated by The MITRE Corporation (MITRE). Copyright © 2006–2025, The MITRE Corporation. CWE, CWSS, CWRAF, and the CWE logo are trademarks of The MITRE Corporation. |