Umbra Wiki weakness weakness/CWE-415
Back to wiki

CWE-415 — Double Free

provenance: imported · CWE: CWE-415

CWE-415: Double Free

MITRE CWE weakness

Kind Weakness
Abstraction Variant
Status Draft
Likelihood of exploit High

Description

The product calls free() twice on the same memory address.

Common consequences

  • Integrity, Confidentiality, Availability: Modify Memory, Execute Unauthorized Code or Commands

Mitigations

Architecture and Design — Choose a language that provides automatic memory management.

Implementation — Ensure that each allocation is freed only once. After freeing a chunk, set the pointer to NULL to ensure the pointer cannot be freed again. In complicated error conditions, be sure that clean-up routines respect the state of allocation properly. If the language is object oriented, ensure that object destructors delete each chunk of memory only once.

Implementation — Use a static analysis tool to find double free instances.

References

  • CWE page: https://cwe.mitre.org/data/definitions/415.html
  • CWE list: https://cwe.mitre.org/data/index.html