detecting-use-after-free

waiwai24's avatarfrom waiwai24

Detects use-after-free vulnerabilities by identifying pointer dereferences after memory deallocation. Use when analyzing memory management, cleanup code, or investigating dangling pointer issues.

⭐0stars🔀0forks📁View on GitHub🕐Updated Dec 26, 2025

When & Why to Use This Skill

This Claude skill specializes in detecting use-after-free vulnerabilities by analyzing memory management patterns and identifying pointer dereferences after deallocation. It enhances software security by automating the identification of dangling pointers, double-free errors, and invalid memory access, providing detailed exploitability assessments and mitigation strategies to prevent memory corruption and code execution exploits.

Use Cases

  • Security Vulnerability Assessment: Automatically scan source code to identify high-risk use-after-free vulnerabilities that could lead to remote code execution or data corruption.
  • Memory Management Debugging: Trace pointer lifecycles and control flows to resolve complex dangling pointer issues and intermittent crashes in C/C++ applications.
  • Secure Code Review: Enhance the peer review process by systematically checking for double-free errors and improper pointer handling during memory cleanup operations.
  • Exploitability Analysis: Evaluate the severity of detected memory issues by determining if an attacker can control freed memory or trigger useful use-after-free conditions.
namedetecting-use-after-free
descriptionDetects use-after-free vulnerabilities by identifying pointer dereferences after memory deallocation. Use when analyzing memory management, cleanup code, or investigating dangling pointer issues.

Use-After-Free Detection

Detection Workflow

  1. Identify free operations: Find all free(), realloc(), delete calls and note the pointer being freed
  2. Trace pointer usage: Use xrefs_to to find all dereferences of the pointer
  3. Check control flow: Analyze paths through code to identify usage after free
  4. Assess exploitability: Can attacker control freed memory? Is there a useful use-after-free? Can memory be reallocated?

Key Patterns

  • Pointer dereference after free()
  • Double free vulnerabilities
  • Invalid pointer access after realloc()
  • Reference counting issues

Output Format

Report with: id, type, subtype, severity, confidence, location, freed pointer, free operation, use operation, use-after-free status, distance, exploitability, attack scenario, impact, mitigation.

Severity Guidelines

  • CRITICAL: Use-after-free with code execution
  • HIGH: Use-after-free with data corruption
  • MEDIUM: Use-after-free causing crashes
  • LOW: Use-after-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