Failure to provide confidentiality for stored data
Non-final public fields should be avoided, if possible, as the code is easily tamperable.
- Integrity: The object could potentially be tampered with.
- Confidentiality: The object could potentially allow the object to be read.
- Implementation: This flaw is a simple logic issue, introduced entirely at implementation time.
- Languages: Java, C++
- Operating platforms: Any
Likelihood of exploit
Avoidance and mitigation
- Implementation: Make any non-final field private.
If a field is non-final and public, it can be changed once their value is set by any function which has access to the class which contains the field.
public int password r = 45;
public String r = new String("My Password");
Now this field is readable from any function and can be changed by any function.