---
title: "CWE-1061: Insufficient Encapsulation"
url: https://radicalnotion.ai/cwe/cwe-1061
type: cwe
description: "The product does not sufficiently hide the internal representation and implementation details of data or methods."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-1061: Insufficient Encapsulation

- **Abstraction:** Class
- **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

The product does not sufficiently hide the internal representation and implementation details of data or methods.

## Modes of introduction

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

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Access Control | Varies by Context, Bypass Protection Mechanism, Modify Application Data | An attacker might be able to use external components or modules to modify data unexpectedly, invoke unexpected functionality, introduce dependencies that the programmer did not intend, or access data or methods that were not intended to be accessible. |
| Other | Reduce Maintainability, Increase Analytical Complexity | This issue makes it more difficult to maintain the product, which indirectly affects security by making it more difficult or time-consuming to find and/or fix vulnerabilities. It also might make it easier to introduce vulnerabilities. |

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

## Demonstrative examples

### Example 1

The following example shows a basic user account class that includes member variables for the username and password as well as a public constructor for the class and a public method to authorize access to the user account.

Bad code:

```c++
#define MAX_PASSWORD_LENGTH 15
#define MAX_USERNAME_LENGTH 15

class UserAccount
{
    public:
        UserAccount(char *username, char *password)
        {
            if ((strlen(username) > MAX_USERNAME_LENGTH) ||
            (strlen(password) > MAX_PASSWORD_LENGTH)) {
                ExitError("Invalid username or password");
            }
            strcpy(this->username, username);
            strcpy(this->password, password);
        }

    int authorizeAccess(char *username, char *password)
    {
        if ((strlen(username) > MAX_USERNAME_LENGTH) ||
        (strlen(password) > MAX_PASSWORD_LENGTH)) {
            ExitError("Invalid username or password");
        }
        // if the username and password in the input parameters are equal to

        // the username and password of this account class then authorize access
        if (strcmp(this->username, username) ||
        strcmp(this->password, password))
            return 0;

        // otherwise do not authorize access
        else
            return 1;
    }

    char username[MAX_USERNAME_LENGTH+1];
    char password[MAX_PASSWORD_LENGTH+1];
};
```

Good code:

```c++
class UserAccount
{
public:
    ...

private:
    char username[MAX_USERNAME_LENGTH+1];
    char password[MAX_PASSWORD_LENGTH+1];
};
```

However, the member variables username and password are declared public and therefore will allow access and changes to the member variables to anyone with access to the object. These member variables should be declared private as shown below to prevent unauthorized access and changes.

## Observed examples

| CVE | Description |
| --- | --- |
| CVE-2010-3860 | variables declared public allow remote read of system properties such as user name and home directory. |

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-710](https://radicalnotion.ai/cwe/cwe-710) | Improper Adherence to Coding Standards |
| Child | [CWE-766](https://radicalnotion.ai/cwe/cwe-766) | Critical Data Element Declared Public |
| Child | [CWE-1054](https://radicalnotion.ai/cwe/cwe-1054) | Invocation of a Control Element at an Unnecessarily Deep Horizontal Layer |
| Child | [CWE-1057](https://radicalnotion.ai/cwe/cwe-1057) | Data Access Operations Outside of Expected Data Manager Component |
| Child | [CWE-1062](https://radicalnotion.ai/cwe/cwe-1062) | Parent Class with References to Child Class |
| Child | [CWE-1083](https://radicalnotion.ai/cwe/cwe-1083) | Data Access from Outside Expected Data Manager Component |
| Child | [CWE-1090](https://radicalnotion.ai/cwe/cwe-1090) | Method Containing Access of a Member Element from Another Class |
| Child | [CWE-1100](https://radicalnotion.ai/cwe/cwe-1100) | Insufficient Isolation of System-Dependent Functions |
| Child | [CWE-1105](https://radicalnotion.ai/cwe/cwe-1105) | Insufficient Encapsulation of Machine-Dependent Functionality |

## Frequently asked questions

### What is CWE-1061?

The product does not sufficiently hide the internal representation and implementation details of data or methods.

### How is CWE-1061 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-1061?

Exploiting CWE-1061 can lead to: Varies by Context, Bypass Protection Mechanism, Modify Application Data, Reduce Maintainability, Increase Analytical Complexity.

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

---

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