---
title: "CWE-767: Access to Critical Private Variable via Public Method"
url: https://radicalnotion.ai/cwe/cwe-767
type: cwe
description: "The product defines a public method that reads or modifies a private variable."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-767: Access to Critical Private Variable via Public Method

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

## Description

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

## Modes of introduction

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

## Applicable platforms

**Languages:** C++ (Undetermined), C# (Undetermined), Java (Undetermined)

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Integrity, Other | Modify Application Data, Varies by Context | 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. |

## Potential mitigations

### Implementation

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.

## Demonstrative examples

### Example 1

The following example declares a critical variable to be private, and then allows the variable to be modified by public methods.

Bad code:

```c++
private: float price;
public: void changePrice(float newPrice) {
    price = newPrice;
}
```

### Example 2

The following example could be used to implement a user forum where a single user (UID) can switch between multiple profiles (PID).

Bad code:

```java
public class Client {
    private int UID;
    public int PID;
    private String userName;
    public Client(String userName){
        PID = getDefaultProfileID();
        UID = mapUserNametoUID( userName );
        this.userName = userName;
    }
    public void setPID(int ID) {
        UID = ID;
    }
}
```

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.

## Real CVEs with this weakness

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2024-36463 | zabbix: atob function allows to create private strings | high | 8.8 | - | No | 2024-11-26 |
| CVE-2020-26868 | ARC Informatique PcVue Access to Critical Private Variable via Public Method | high | 7.5 | - | No | 2020-10-12 |
| CVE-2016-8380 | - | high | 7.3 | - | No | 2018-04-05 |
| CVE-2025-38392 | idpf: convert control queue mutex to a spinlock | medium | 5.5 | - | No | 2025-07-25 |
| CVE-2024-34162 | - | medium | 5.3 | - | No | 2024-11-26 |

## 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 |
| --- | --- | --- | --- |
| CLASP | Failure to protect stored data from modification | - | - |
| Software Fault Patterns | Exposed Data | SFP23 | - |
| SEI CERT Perl Coding Standard | Do not access private variables or subroutines in other packages | OOP31-PL | Imprecise |

## Frequently asked questions

### What is CWE-767?

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

### What CVEs are caused by CWE-767?

5 recorded CVEs are attributed to CWE-767, including CVE-2024-36463, CVE-2020-26868 and CVE-2016-8380.

### How do you prevent CWE-767?

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.

### What are the consequences of CWE-767?

Exploiting CWE-767 can lead to: Modify Application Data, Varies by Context.

### Is CWE-767 actively exploited?

5 recorded CVEs are caused by CWE-767; none are currently in CISA's KEV catalog of actively exploited flaws.

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

---

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