COMMON WEAKNESS ENUMERATIONIncomplete

CWE-767

Access to Critical Private Variable via Public Method

The product defines a public method that reads or modifies a private variable.

Abstraction

Base

Structure

Simple

Likelihood of Exploit

Medium

Understand the problem

What is the problem?

The product defines a public method that reads or modifies a private variable.

Extended description

If an attacker modifies the variable to contain unexpected values, this could violate assumptions from other parts of the code. Additionally, if an attacker can read the private variable, it may expose sensitive information or make it easier to launch further attacks.

Root cause

How and when does the problem arise?

Lifecycle phase

Implementation

Risk

What does successful exploitation lead to?

Modify Application DataOther

Affected security scopes: Integrity, Other

Defence

How is it prevented and fixed?

Implementation

Implementation-phase defence

Detail
Use class accessor and mutator methods appropriately. Perform validation when accepting data from a public method that is intended to modify a critical private variable. Also be sure that appropriate access controls are being applied when a public method interfaces with critical data.