Skip to main content

CWE-495: Private Data Structure Returned From A Public Method

VariantDraft

The product has a method that is declared public, but returns a reference to a private data structure, which could then be modified in unexpected ways.

View on MITRE
Back to CWE Lookup

Technical Details

Structure
Simple

Applicable To

Languages
CC++JavaC#
Platforms

Frequently Asked Questions

What is CWE-495: Private Data Structure Returned From A Public Method?+

CWE-495: Private Data Structure Returned From A Public Method is a Common Weakness Enumeration (CWE) entry maintained by MITRE. The product has a method that is declared public, but returns a reference to a private data structure, which could then be modified in unexpected ways.

What are the security consequences of Private Data Structure Returned From A Public Method?+

If exploited, CWE-495 (Private Data Structure Returned From A Public Method) it can compromise Integrity, leading to outcomes such as Modify Application Data.

How do you prevent or mitigate Private Data Structure Returned From A Public Method?+

Recommended mitigations for CWE-495 include: Declare the method private. Clone the member data and keep an unmodified version of the data private to the object. Use public setter methods that govern how a private member can be modified.

Which programming languages are affected by Private Data Structure Returned From A Public Method?+

CWE-495 commonly affects C, C++, Java and C#. Note that weaknesses are often language-agnostic patterns, so secure coding practices apply broadly.

What is the difference between a CWE and a CVE?+

A CWE (Common Weakness Enumeration) like CWE-495 describes a category of software weakness — the underlying flaw type. A CVE (Common Vulnerabilities and Exposures) identifies a specific, real-world vulnerability in a particular product. In short, a CWE is the kind of mistake, and a CVE is an instance of that mistake being found in software.

Learn More