|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
CWE-493: Critical Public Variable Without Final Modifier
Description Summary The product has a critical public variable that is not final, which allows the variable to be modified to contain unexpected values.
Extended Description If a field is non-final and public, it can be changed once the value is set by any function that has access to the class which contains the field. This could lead to a vulnerability if other parts of the program make assumptions about the contents of that field.
Example 1 Suppose this WidgetData class is used for an e-commerce web site. The programmer attempts to prevent price-tampering attacks by setting the price of the widget using the constructor. (Bad Code) Example
Language: Java public final class WidgetData extends Applet { public float price;
...
public WidgetData(...) {
this.price = LookupPrice("MyWidgetType");
}
} The price field is not final. Even though the value is set by the constructor, it could be modified by anybody that has access to an instance of WidgetData. Example 2 Assume the following code is intended to provide the location of a configuration file that controls execution of the application. (Bad Code) Example
Language: C++ public string configPath = "/etc/application/config.dat"; (Bad Code) Example
Language: Java public String configPath = new
String("/etc/application/config.dat"); While this field is readable from any function, and thus might allow an information leak of a pathname, a more serious problem is that it can be changed by any function.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Page Last Updated:
September 12, 2011
|
|
CWE is a Software Assurance strategic initiative co-sponsored by the National Cyber Security Division of the U.S. Department of Homeland Security. This Web site is sponsored and managed by The MITRE Corporation to enable stakeholder collaboration. Copyright © 2006-2012, The MITRE Corporation. CWE, CWSS, CWRAF, and the CWE logo are trademarks of The MITRE Corporation. Contact cwe@mitre.org for more information. |
|||



