detecting-double-free

Detects double free vulnerabilities by identifying attempts to free the same memory block twice. Use when analyzing memory management, cleanup paths, or investigating heap corruption issues.

⭐5stars🔀1forks📁View on GitHub🕐Updated Jan 11, 2026

When & Why to Use This Skill

This Claude skill provides an automated solution for detecting double free vulnerabilities, a critical memory management error where the same memory block is deallocated multiple times. By analyzing control flow, pointer aliasing, and cleanup paths, it helps developers and security researchers prevent heap corruption, system instability, and high-severity security exploits such as Remote Code Execution (RCE).

Use Cases

  • Security Auditing: Proactively scanning C/C++ codebases during the code review phase to identify CWE-415 (Double Free) vulnerabilities before deployment.
  • Root Cause Analysis: Investigating intermittent heap-related crashes or memory corruption issues by tracing pointer usage and identifying redundant free() or delete calls.
  • Legacy Code Refactoring: Analyzing complex cleanup logic and reference counting in older projects to ensure memory safety is maintained during architectural changes.
  • Exploitability Assessment: Evaluating the impact of identified memory management flaws to determine if they can be leveraged by attackers for code execution or denial of service.
namedetecting-double-free
descriptionDetects double free vulnerabilities by identifying attempts to free the same memory block twice. Use when analyzing memory management, cleanup paths, or investigating heap corruption issues.

Double Free Detection

Detection Workflow

  1. Identify free operations: Find all free() and delete/delete[] calls, note the pointers being freed
  2. Track pointer usage: Use xrefs_to to trace pointers and identify pointer aliases
  3. Analyze control flow: Map all code paths to free(), check for multiple free() calls on same pointer
  4. Assess exploitability: Can attacker trigger double free? Is there useful heap corruption?

Key Patterns

  • Direct double free: free() called twice on same pointer
  • Conditional double free: free() in multiple code paths
  • Indirect double free: freeing same memory through different pointers
  • Reference counting issues

Output Format

Report with: id, type, subtype, severity, confidence, location, freed pointer, first free, second free, double free path, exploitability, attack scenario, impact, mitigation.

Severity Guidelines

  • CRITICAL: Double free with code execution potential
  • HIGH: Double free causing heap corruption
  • MEDIUM: Double free causing crashes
  • LOW: Double free with limited impact

See Also

  • patterns.md - Detailed detection patterns and exploitation scenarios
  • examples.md - Example analysis cases and code samples
  • references.md - CWE references and mitigation strategies