结构: Simple
Abstraction: Variant
状态: Draft
被利用可能性: High
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.
cwe_Nature: ChildOf cwe_CWE_ID: 493 cwe_View_ID: 1000 cwe_Ordinal: Primary
cwe_Nature: ChildOf cwe_CWE_ID: 493 cwe_View_ID: 699 cwe_Ordinal: Primary
Language: [{'cwe_Name': 'C++', 'cwe_Prevalence': 'Undetermined'}, {'cwe_Name': 'Java', 'cwe_Prevalence': 'Undetermined'}]
范围 | 影响 | 注释 |
---|---|---|
Integrity | Modify Application Data | The object could potentially be tampered with. |
Confidentiality | Read Application Data | The object could potentially allow the object to be read. |
策略:
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
The following examples use of a public static String variable to contain the name of a property/configuration file for the application.
bad C++
bad Java
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 C++
good Java
映射的分类名 | ImNode ID | Fit | Mapped Node Name |
---|---|---|---|
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 |