结构: Simple
Abstraction: Variant
状态: Incomplete
被利用可能性: unkown
The software defines a public method that reads or modifies a private variable.
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.
Language: [{'cwe_Name': 'C++', 'cwe_Prevalence': 'Undetermined'}, {'cwe_Name': 'C#', 'cwe_Prevalence': 'Undetermined'}, {'cwe_Name': 'Java', 'cwe_Prevalence': 'Undetermined'}]
范围 | 影响 | 注释 |
---|---|---|
['Integrity', 'Other'] | ['Modify Application Data', 'Other'] |
策略:
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.
The following example declares a critical variable to be private, and then allows the variable to be modified by public methods.
bad C++
The following example could be used to implement a user forum where a single user (UID) can switch between multiple profiles (PID).
bad Java
The programmer implemented setPID with the intention of modifying the PID variable, but due to a typo. accidentally specified the critical variable UID instead. If the program allows profile IDs to be between 1 and 10, but a UID of 1 means the user is treated as an admin, then a user could gain administrative privileges as a result of this typo.
映射的分类名 | ImNode ID | Fit | Mapped Node Name |
---|---|---|---|
CLASP | Failure to protect stored data from modification | ||
Software Fault Patterns | SFP23 | Exposed Data | |
SEI CERT Perl Coding Standard | OOP31-PL | Imprecise | Do not access private variables or subroutines in other packages |