Common Weakness Enumeration

A Community-Developed List of Software Weakness Types

CWE/SANS Top 25 Most Dangerous Software Errors
Home > CWE List > CWE- Individual Dictionary Definition (2.11)  

CWE-500: Public Static Field Not Marked Final

Weakness ID: 500
Abstraction: Variant
Status: Draft
Presentation Filter:
+ Description

Description Summary

An object contains a public static field that is not marked final, which might allow it to be modified in unexpected ways.

Extended Description

Public static variables can be read without an accessor and changed without a mutator by any classes in the application.

+ Time of Introduction
  • Implementation
+ Applicable Platforms




+ Common Consequences

Technical Impact: Modify application data

The object could potentially be tampered with.


Technical Impact: Read application data

The object could potentially allow the object to be read.

+ Likelihood of Exploit


+ Demonstrative Examples

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 {

static string appPropertiesConfigFile = "app/properties.config";
(Bad Code)
Example Language: Java 
public class SomeAppClass {

public static String appPropertiesFile = "app/";

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 {

static const string appPropertiesConfigFile = "app/properties.config";
(Good Code)
Example Language: Java 
public class SomeAppClass {

public static final String appPropertiesFile = "app/";
+ Potential Mitigations

Phase: Architecture and Design

Clearly identify the scope for all critical data elements, including whether they should be regarded as static.

Phase: Implementation

Make any static fields private and constant.

A constant field is denoted by the keyword 'const' in C/C++ and ' final' in Java

+ Background Details

When a field is declared public but not final, the field can be read and written to by arbitrary Java code.

+ Relationships
NatureTypeIDNameView(s) this relationship pertains toView(s)
ChildOfWeakness VariantWeakness Variant493Critical Public Variable Without Final Modifier
Development Concepts (primary)699
Research Concepts (primary)1000
ChildOfCategoryCategory849CERT Java Secure Coding Section 04 - Object Orientation (OBJ)
Weaknesses Addressed by the CERT Java Secure Coding Standard (primary)844
ChildOfCategoryCategory1002SFP Secondary Cluster: Unexpected Entry Points
Software Fault Pattern (SFP) Clusters (primary)888
+ Taxonomy Mappings
Mapped Taxonomy NameNode IDFitMapped Node Name
CLASPOverflow of static internal buffer
CERT Java Secure CodingOBJ10-JDo not use public static nonfinal variables
Software Fault PatternsSFP28Unexpected access points
+ White Box Definitions

A weakness where code path has a statement that defines a public field that is static and non-final

+ Content History
Submission DateSubmitterOrganizationSource
CLASPExternally Mined
Modification DateModifierOrganizationSource
2008-07-01Eric DalciCigitalExternal
updated Time_of_Introduction
2008-08-01KDM AnalyticsExternal
added/updated white box definitions
2008-09-08CWE Content TeamMITREInternal
updated Applicable_Platforms, Common_Consequences, Relationships, Other_Notes, Taxonomy_Mappings
2008-11-05CWE Content TeamMITREInternal
Significant clarification of this entry, and improved examples.
2008-11-24CWE Content TeamMITREInternal
updated Background_Details, Demonstrative_Examples, Description, Name, Other_Notes, Potential_Mitigations
2009-05-27CWE Content TeamMITREInternal
updated Relationships
2011-06-01CWE Content TeamMITREInternal
updated Common_Consequences, Relationships, Taxonomy_Mappings
2012-05-11CWE Content TeamMITREInternal
updated Relationships, Taxonomy_Mappings
2012-10-30CWE Content TeamMITREInternal
updated Demonstrative_Examples, Description, Potential_Mitigations
2014-07-30CWE Content TeamMITREInternal
updated Relationships, Taxonomy_Mappings
Previous Entry Names
Change DatePrevious Entry Name
2008-04-11Overflow of Static Internal Buffer
2008-11-24Static Field Not Marked Final

More information is available — Please select a different filter.
Page Last Updated: May 05, 2017