CWE-415: Double Free

What is CWE-415?

MITRE CWE

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

Verify to analyze this CWE entry

A short verification protects the official data source and prevents automated AI abuse.

Official definition

MITRE CWE

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

Detailed description

CyStack is analyzing this CWE entry. The page will update automatically when the bilingual analysis is ready.

Characteristics

CyStack is analyzing this CWE entry. The page will update automatically when the bilingual analysis is ready.
  • Double-free

Modes of introduction

  • Implementation

Common consequences

CyStack is analyzing this CWE entry. The page will update automatically when the bilingual analysis is ready.
  • Integrity, Confidentiality, Availability

    Modify Memory, Execute Unauthorized Code or Commands

    When 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.

Mitigations

CyStack is analyzing this CWE entry. The page will update automatically when the bilingual analysis is ready.
  • Architecture and DesignChoose a language that provides automatic memory management.
  • 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.
  • ImplementationUse a static analysis tool to find double free instances.

Detection methods

CyStack is analyzing this CWE entry. The page will update automatically when the bilingual analysis is ready.
  • 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.Effectiveness: 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.)Effectiveness: 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].Effectiveness: ModerateCrafted 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.

Representative vulnerabilities

CyStack is analyzing this CWE entry. The page will update automatically when the bilingual analysis is ready.

These examples illustrate this CWE entry and are not an exhaustive list of related vulnerabilities.

  • CVE-2006-5051Chain: Signal handler contains too much functionality (CWE-828), introducing a race condition (CWE-362) that leads to a double free (CWE-415).
  • CVE-2004-0642Double free resultant from certain error conditions.
  • CVE-2004-0772Double free resultant from certain error conditions.
  • CVE-2005-1689Double free resultant from certain error conditions.
  • CVE-2003-0545Double free from invalid ASN.1 encoding.
  • CVE-2003-1048Double free from malformed GIF.
  • CVE-2005-0891Double free from malformed GIF.
  • CVE-2002-0059Double free from malformed compressed data.

Sources and references

References

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.

Explore CyStack VulnScan
CyStack VulnScan dashboard