---
title: "CWE-496: Public Data Assigned to Private Array-Typed Field"
url: https://radicalnotion.ai/cwe/cwe-496
type: cwe
description: "Assigning public data to a private array is equivalent to giving public access to the array."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-496: Public Data Assigned to Private Array-Typed Field

- **Abstraction:** Variant
- **Structure:** Simple
- **Status:** Incomplete
- **CVEs with this as primary weakness:** 0
- **Of those, in CISA KEV:** 0
- **New in 2026:** 0
- **CWE catalog version:** 4.21

## Description

Assigning public data to a private array is equivalent to giving public access to the array.

## Modes of introduction

| Phase | Note |
| --- | --- |
| Implementation | - |

## Applicable platforms

**Languages:** Object-Oriented (Undetermined), C (Undetermined), C++ (Undetermined), Java (Undetermined), C# (Undetermined)

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Integrity | Modify Application Data | The contents of the array can be modified from outside the intended scope. |

## Potential mitigations

### Implementation

Do not allow objects to modify private members of a class.

## Detection methods

### 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

## Demonstrative examples

### Example 1

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.

Bad code:

```java
private String[] userRoles;
public void setUserRoles(String[] userRoles) {
    this.userRoles = userRoles;
}
```

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-668](https://radicalnotion.ai/cwe/cwe-668) | Exposure of Resource to Wrong Sphere |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| 7 Pernicious Kingdoms | Public Data Assigned to Private Array-Typed Field | - | - |
| Software Fault Patterns | Tainted input to variable | SFP25 | - |

## Frequently asked questions

### 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.

Primary source: [MITRE CWE](https://cwe.mitre.org/data/definitions/496.html)

---

Source: [RadicalNotion.AI](https://radicalnotion.ai/cwe/cwe-496). Licensed CC BY-NC 4.0; attribute RadicalNotion.AI and link the source page when you reuse this data.
