detecting-race-conditions

Detects race condition vulnerabilities including TOCTOU, double-checked locking issues, and shared state problems. Use when analyzing concurrent operations, file access patterns, or investigating timing-related vulnerabilities.

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

When & Why to Use This Skill

This Claude skill automates the detection of complex race condition vulnerabilities, including TOCTOU (Time-of-Check to Time-of-Use), double-checked locking flaws, and unprotected shared state issues. By analyzing concurrent execution paths and synchronization primitives, it helps developers and security researchers identify critical timing-related bugs and potential exploit vectors in multi-threaded or asynchronous environments, significantly enhancing software reliability and security posture.

Use Cases

  • Security Auditing: Identifying TOCTOU vulnerabilities in file system interactions where a file might be modified between its validation and its use.
  • Concurrency Debugging: Tracing execution paths in multi-threaded applications to find unprotected shared variables and non-atomic operations that lead to data corruption.
  • Code Quality Assurance: Verifying the correctness of synchronization primitives and lock ordering to prevent deadlocks and race conditions during automated code reviews.
  • Vulnerability Research: Assessing the exploitability of timing-related issues by analyzing race windows and potential attacker-controlled timing in critical operations.
namedetecting-race-conditions
descriptionDetects race condition vulnerabilities including TOCTOU, double-checked locking issues, and shared state problems. Use when analyzing concurrent operations, file access patterns, or investigating timing-related vulnerabilities.

Race Condition Detection

Detection Workflow

  1. Identify critical operations: Find file access sequences (check then use), shared state access patterns, synchronization primitives
  2. Trace execution paths: Use xrefs_to to identify potential interleaving points and race windows
  3. Check synchronization: Verify locks protect critical sections, check for atomic operations, assess lock ordering
  4. Assess exploitability: Can attacker control timing? Is there a useful race window? What's the impact?

Key Patterns

  • TOCTOU (Time-of-Check to Time-of-Use)
  • Double-checked locking issues
  • Unprotected shared variables
  • Non-atomic operations on shared data
  • Signal handler issues

Output Format

Report with: id, type, subtype, severity, confidence, location, vulnerability, check operation, use operation, race window, exploitability, attack scenario, impact, mitigation.

Severity Guidelines

  • CRITICAL: Race allowing privilege escalation
  • HIGH: Race allowing file access bypass
  • MEDIUM: Race causing data corruption
  • LOW: Race with minor 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