From soundcheck
Flags race conditions (CWE-362) in check-then-act sequences on shared state, file operations, balance updates, and counters. Suggests atomic fixes with locks, transactions, CAS.
npx claudepluginhub thejefflarson/soundcheck --plugin soundcheckThis skill uses the workspace's default tool permissions.
Protects against time-of-check-to-time-of-use (TOCTOU) and other race conditions where
Detects race conditions in PHP code including check-then-act patterns, TOCTOU vulnerabilities, shared mutable state, read-modify-write issues, file/DB/session races. Includes grep patterns for scanning.
Tests web apps for race conditions, single-packet attacks, TOCTOU vulnerabilities, double-spends, rate limit bypasses, and concurrency issues via endpoint analysis and HTTP/2 manifests.
Implements concurrent operations in Python asyncio and Rust Tokio, preventing race conditions, ensuring resource safety, and optimizing performance with TDD workflows.
Share bugs, ideas, or general feedback.
Protects against time-of-check-to-time-of-use (TOCTOU) and other race conditions where concurrent access to shared state creates a window for attackers to manipulate data between a check and its corresponding action. Exploitation leads to privilege escalation, double-spend, and data corruption.
if os.path.exists(f): os.remove(f) — file can be swapped between check and removeif user.balance >= amount: user.balance -= amount — double-spend without lockingcount = db.get(key); db.set(key, count + 1) — lost update under concurrencyif !exists(username) { create(username) } — duplicate creation raceFlag the vulnerable code and explain the risk. Then suggest a fix that establishes these properties:
SELECT followed by
a separate UPDATE is the exact bug — merge them into a conditional
UPDATE ... WHERE that returns the affected row count.rename,
link, O_CREAT|O_EXCL, os.makedirs(exist_ok=False). os.path.exists()
followed by os.open() is TOCTOU-exploitable; the atomic flag short-circuits
the window.if !exists() { create() } races two ways with itself; a UNIQUE index
plus an insert-and-catch-duplicate pattern is race-free by construction.Anchor — shape, not implementation:
# atomic DB update with guard
rows = db.execute("UPDATE accounts SET balance = balance - ? "
"WHERE id = ? AND balance >= ?", [amount, id, amount])
require(rows == 1) # rowcount is the "check"
# atomic file create
fd = open(path, O_CREAT | O_EXCL) # fails if it already exists