CWE-1061: Insufficient Encapsulation
The product does not sufficiently hide the internal representation and implementation details of data or methods, which might allow external components or modules to modify data unexpectedly, invoke unexpected functionality, or introduce dependencies that the programmer did not intend.
How it's found
Insufficient Encapsulation describes a general pattern rather than a single fixed bug. Testers use a mix of static analysis and manual code review to find where a target's code matches this pattern, then confirm exploitability by hand.
Vulnerable vs. safe
ExitError("Invalid username or password");if ((strlen(username) > MAX_USERNAME_LENGTH) ||(strlen(password) > MAX_PASSWORD_LENGTH)) {}strcpy(this->username, username);strcpy(this->password, password);UserAccount(char *username, char *password){}
ExitError("Invalid username or password");
return 0;
return 1;// if the username and password in the input parameters are equal to
// the username and password of this account class then authorize access
// otherwise do not authorize accessif ((strlen(username) > MAX_USERNAME_LENGTH) ||(strlen(password) > MAX_PASSWORD_LENGTH)) {}if (strcmp(this->username, username) ||strcmp(this->password, password))else
public:int authorizeAccess(char *username, char *password){}char username[MAX_USERNAME_LENGTH+1];char password[MAX_PASSWORD_LENGTH+1];#define MAX_PASSWORD_LENGTH 15#define MAX_USERNAME_LENGTH 15class UserAccount{};...
char username[MAX_USERNAME_LENGTH+1];char password[MAX_PASSWORD_LENGTH+1];class UserAccount{public:private:};Consequences
- Varies by Context, Bypass Protection Mechanism: An attacker can access data or methods that were not intended to be accessible.
- 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.
Where this fits in a TurboPentest engagement
This weakness is not covered by the automated black-box pentest. IntegSec pentesters cover it in a manual engagement.
Frequently asked questions
What is CWE-1061?
The product does not sufficiently hide the internal representation and implementation details of data or methods, which might allow external components or modules to modify data unexpectedly, invoke unexpected functionality, or introduce dependencies that the programmer did not intend.
How do you find Insufficient Encapsulation?
Insufficient Encapsulation describes a general pattern rather than a single fixed bug. Testers use a mix of static analysis and manual code review to find where a target's code matches this pattern, then confirm exploitability by hand.
What is the impact of CWE-1061?
Varies by Context, Bypass Protection Mechanism: An attacker can access data or methods that were not intended to be accessible. 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.
Does TurboPentest test for Insufficient Encapsulation?
This weakness is not covered by the automated black-box pentest. IntegSec pentesters cover it in a manual engagement.
Related CWEs
Written and reviewed by
Michel Chamberland - Founder & CEO, IntegSec
CISSP, OSCP, OSCE, CEH, GIAC, CCSK · 20+ years in offensive security
Michel has spent 20+ years on offensive security teams including IBM X-Force Red and Trustwave SpiderLabs, leading penetration tests, red team engagements, and breach response for Fortune 500 customers. He is the founder of IntegSec and the architect of TurboPentest.
Find these issues before an attacker does
TurboPentest runs an agentic AI pentest against your target and reports findings with proof, from $99 per target.
Start a pentest