Katalog CWE

CWE-416 · Słabość

Use After Free

Abstrakcja
Wariant
Status
Stabilny
Ryzyko wykorzystania
wysokie
Dodano
19 lipca 2006
Ostatnia zmiana
30 kwietnia 2026

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

Opis

The product reuses or references memory after it has been freed. At some point afterward, the memory may be allocated again and saved in another pointer, while the original pointer references a location somewhere within the new allocation. Any operations using the original pointer are no longer valid because the memory "belongs" to the code that operates on the new pointer.

Inne nazwy

Dangling pointer
a pointer that no longer points to valid memory, often after it has been freed
UAF
commonly used acronym for Use After Free
Use-After-Free

Skutki

  • Integrity

    Modify Memory

    The use of previously freed memory may corrupt valid data, if the memory area in question has been allocated and used properly elsewhere.

  • Availability

    DoS: Crash, Exit, or Restart

    If chunk consolidation occurs after the use of previously freed data, the process may crash when invalid data is used as chunk information.

  • Confidentiality

    Read Memory

    Read operations on freed memory can sometimes leak sensitive information instead of causing a crash

  • Integrity, Confidentiality, Availability

    Execute Unauthorized Code or Commands

    If malicious data is entered before chunk consolidation can take place, it may be possible to take advantage of a write-what-where primitive to execute arbitrary code. If the newly allocated data happens to hold a class, in C++ for example, various function pointers may be scattered within the heap data. If one of these function pointers is overwritten with an address to valid shellcode, execution of arbitrary code can be achieved.

Zapobieganie

  • Architecture and Design · Language Selection

    Choose a language that provides automatic memory management.

  • Implementation · Attack Surface Reduction

    When freeing pointers, be sure to set them to NULL once they are freed. However, the utilization of multiple or complex data structures may lower the usefulness of this strategy.

    Skuteczność: Defense in Depth

Przykłady podatności

Słabość nadrzędna

Może prowadzić do

Kiedy powstaje

Dotyczy

Memory-Unsafe, C, C++

Źródła

  1. Seven Pernicious Kingdoms: A Taxonomy of Software Security Errors — Katrina Tsipenyuk, Brian Chess, Gary McGraw, NIST, 2005
  2. The CLASP Application Security Process — Secure Software, Inc., 2005
  3. 24 Deadly Sins of Software Security — Michael Howard, David LeBlanc, John Viega, "Sin 8: C++ Catastrophes." Page 143, McGraw-Hill, 2010
  4. AddressSanitizer

Wpis z katalogu CWE 4.20.