CWE-495

Private Data Structure Returned From A Public Method

Medium

Description

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.

Potential Impact

How to Fix

Implementation

Declare the method private.

Implementation

Clone the member data and keep an unmodified version of the data private to the object.

Implementation

Use public setter methods that govern how a private member can be modified.

Detection Methods

Related Weaknesses

References

View on MITRE CWE Database →

Need Help Fixing This Vulnerability?

Our security experts can help you identify and remediate CWE-495 vulnerabilities in your codebase.

Get Security Assessment