The product has a critical public variable that is not final, which allows the variable to be modified to contain unexpected values.
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.
Threat Mapped score: 0.0
Industry: Finiancial
Threat priority: Unclassified
N/A
N/A
Phase | Note |
---|---|
Implementation | N/A |
Intro: 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.
Body: 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.
public final class WidgetData extends Applet { public float price; ... public WidgetData(...) { this.price = LookupPrice("MyWidgetType"); } }
Intro: Assume the following code is intended to provide the location of a configuration file that controls execution of the application.
Body: 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.
public string configPath = "/etc/application/config.dat";