Public Static Final Field References Mutable Object
Weakness ID: 607 (Weakness Variant)Status: Draft
+ Description

Description Summary

A public or protected static final field references a mutable object, which allows the object to be changed by malicious code, or accidentally from another package
+ Time of Introduction
  • Implementation
+ Applicable Platforms

Languages

Java

+ Demonstrative Examples

Example 1

Here, an array (which is inherently mutable) is labeled public static final.

(Bad Code)
Example Language: Java 
public static final String[] USER_ROLES;
+ Potential Mitigations

Protect mutable objects by making them private. Restrict access to the getter and setter as well.

+ Relationships
NatureTypeIDNameView(s) this relationship pertains toView(s)
ChildOfWeakness BaseWeakness Base471Modification of Assumed-Immutable Data (MAID)
Development Concepts699
Research Concepts (primary)1000
ChildOfWeakness ClassWeakness Class485Insufficient Encapsulation
Development Concepts (primary)699
+ Content History
Submissions
Submission DateSubmitterOrganizationSource
Anonymous Tool Vendor (under NDA)Externally Mined
Modifications
Modification DateModifierOrganizationSource
2008-07-01Sean EidemillerCigitalExternal
added/updated demonstrative examples
2008-07-01Eric DalciCigitalExternal
updated Potential Mitigations, Time of Introduction
2008-09-08CWE Content TeamMITREInternal
updated Relationships, Taxonomy Mappings