Katalog CWE

CWE-375 · Słabość

Returning a Mutable Object to an Untrusted Caller

Abstrakcja
Bazowa
Status
Szkic
Ryzyko wykorzystania
średnie
Dodano
19 lipca 2006
Ostatnia zmiana
11 grudnia 2025

Podatności CVE z tą słabościąPełny wpis na cwe.mitre.org ↗

Opis

Sending non-cloned mutable data as a return value may result in that data being altered or deleted by the calling function.

In situations where functions return references to mutable data, it is possible that the external code which called the function may make changes to the data sent. If this data was not previously cloned, the class will then be using modified data which may violate assumptions about its internal state.

Skutki

  • Access Control, Integrity

    Modify Memory

    Potentially data could be tampered with by another function which should not have been tampered with.

Zapobieganie

  • Implementation

    Declare returned data which should not be altered as constant or immutable.

  • Implementation

    Clone all mutable data before returning references to it. This is the preferred mitigation. This way, regardless of what changes are made to the data, a valid copy is retained for use by the class.

Słabość nadrzędna

Kiedy powstaje

Dotyczy

Object-Oriented, C, C++, Java, C#

Źródła

  1. The CLASP Application Security Process — Secure Software, Inc., 2005

Wpis z katalogu CWE 4.20.