CWE-415: Double Free

What is CWE-415?

CWE-415 is Double Free. The flaw arises when the product calls free() twice on the same memory address. The database currently holds 151 vulnerabilities mapped to CWE-415 and 1 of them are in the CISA Known Exploited Vulnerabilities catalog.

OWASP Top 10 Rank-
Related CVES (365 days)151
AbstractionVariant
Likelihood of exploitHigh

Vulnerabilities mapped to CWE-415

151 vulnerabilities557% increase year over year

Vulnerabilities in CISA KEV for CWE-415

1 vulnerabilities

Official definition

ByMitre CWE

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

Characteristics

Alternate terms

  • Double-free

Modes of introduction

  • Implementation

Common consequences

ImpactScopeExplanation
Modify Memory, Execute Unauthorized Code or CommandsIntegrity, Confidentiality, AvailabilityWhen a program calls free() twice with the same argument, the program's memory management data structures may become corrupted, potentially leading to the reading or modification of unexpected memory addresses. This corruption can cause the program to crash or, in some circumstances, cause two later calls to malloc() to return the same pointer. If malloc() returns the same value twice and the program later gives the attacker control over the data that is written into this doubly-allocated memory, the program becomes vulnerable to a buffer overflow attack. Doubly freeing memory may result in a write-what-where condition, allowing an attacker to execute arbitrary code.

Risk mitigations

  1. Architecture and DesignChoose a language that provides automatic memory management.
  2. ImplementationEnsure 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.
  3. ImplementationUse a static analysis tool to find double free instances.

Detection methods

MethodApproachEffectiveness
FuzzingFuzz testing (fuzzing) is a powerful technique for generating large numbers of diverse inputs - either randomly or algorithmically - and dynamically invoking the code with those inputs. Even with random inputs, it is often capable of generating unexpected results such as crashes, memory corruption, or resource consumption. Fuzzing effectively produces repeatable test cases that clearly indicate bugs, which helps developers to diagnose the issues.High
Automated Static AnalysisAutomated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)High
Automated Dynamic AnalysisUse tools that are integrated during compilation to insert runtime error-checking mechanisms related to memory safety errors, such as AddressSanitizer (ASan) for C/C++ [REF-1518].Crafted inputs are necessary to reach the code containing the error, such as generated by fuzzers. Also, these tools may reduce performance, and they only report the error condition - not the original mistake that led to the error.Moderate

Representative vulnerabilities

Sources (2)

CWE™ Program, operated by The MITRE Corporation. Copyright © 2006–2026, The MITRE Corporation. The MITRE Corporation hereby grants you a non-exclusive, royalty-free license to use CWE for research, development, and commercial purposes. CWE Terms of Use.

Learn more

Run an in-depth assessment with complete web risk management

CyStack VulnScan continuously discovers assets, validates vulnerabilities, and helps security teams prioritize remediation across the organization.