Description

Design through Implementation: At design time it is important to reduce the total amount of accessible data.

Implementation: Most implementation level issues come from a lack of understanding of the language modifiers.

Platform

Languages: Java, C++

Operating platforms: Any

Required resources

Any

Severity

Medium

Likelihood of exploit

Medium

One of the main advantages of object-oriented code is the ability to limit access to fields and other resources by way of accessor functions. Utilize accessor functions to make sure your objects are well-formed.

Final provides security by only allowing non-mutable objects to be changed after being set. However, only objects which are not extended can be made final.

Design through Implementation: Use private members, and class accessor methods to their full benefit. This is the recommended mitigation. Make all public members private, and - if external access is necessary - use accessor functions to do input validation on all values.

Implementation: Data should be private, static, and final whenever possible This will assure that your code is protected by instantiating early, preventing access and preventing tampering.