CWE-496: Public Data Assigned to Private Array-Typed Field
Assigning public data to a private array is equivalent to giving public access to the array.
Last updated
Overview
CWE-496 (Public Data Assigned to Private Array-Typed Field) is a variant-level software weakness catalogued by MITRE in the Common Weakness Enumeration (CWE). It describes a recurring type of mistake that can lead to exploitable security vulnerabilities.
Common consequences
What can happen when CWE-496 is exploited.
Modify Application Data
Affects: Integrity
The contents of the array can be modified from outside the intended scope.
How it happens
When it is introduced
Typically introduced during these phases of the software lifecycle.
Applies to
Languages
How to prevent it
Practical mitigations for CWE-496, grouped by where in the lifecycle they apply.
Do not allow objects to modify private members of a class.
How to detect it
Automated Static Analysis
Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)
Effectiveness: High
Code examples
Illustrative examples from MITRE showing how the weakness appears in code.
In the example below, the setRoles() method assigns a publically-controllable array to a private field, thus allowing the caller to modify the private array directly by virtue of the fact that arrays in Java are mutable.
Vulnerable example
private String[] userRoles;Terminology & mappings
Mapped taxonomies
- 7 Pernicious Kingdoms: Public Data Assigned to Private Array-Typed Field
- Software Fault Patterns: Tainted input to variable (SFP25)
Frequently asked questions
Common questions about CWE-496.
- What is CWE-496?
- Assigning public data to a private array is equivalent to giving public access to the array.
- How do you prevent CWE-496?
- Do not allow objects to modify private members of a class.
- How is CWE-496 detected?
- Automated Static Analysis: Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)
- What are the consequences of CWE-496?
- Exploiting CWE-496 can lead to: Modify Application Data.
References
- MITRE CWE definition (CWE-496) (opens in a new tab)
- CWE-496 vulnerabilities on NVD (opens in a new tab)
- Learn: What is a CWE?
Weakness data is sourced from the MITRE CWE catalog (v4.20). CVE associations are aggregated and kept current by RadicalNotion.AI.
Stay ahead of CWE-496
Get alerted the moment a new CWE-496 vulnerability affects your stack, with AI-written analysis, severity context, and remediation guidance.