/security-agent-skills:detecting-race-conditionsfrom security-agent-skills
Finds concurrency bugs (TOCTOU, unsynchronized shared state, check-then-act, atomicity violations) by reasoning about shared state, interleaving, and windows between checks and uses. For multithreaded code, shared caches/counters, filesystem checks, or verify-then-act sequences.
Ships in security-agent-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Race bugs don't live in one line - they live in the gap between two operations that another actor can slip through. There's no tainted value to trace and no single sink to grep; you find them by asking what state is shared, what runs concurrently, and where a window opens between deciding something and acting on it. This skill covers the recurring shapes and how to confirm a real window.
Authorized source only. If you can't name the authorization, stop.
Confirmation of a race is an interleaving witness: two concrete operation orders where one is safe and the other, achievable by an attacker, is not.
TOCTOU (time-of-check to time-of-use). State is validated, then used, and
it can change in between. Classic filesystem form: access(path) /
stat(path) then open(path) - a symlink swap in the window redirects the
open. General form: any check(x); … ; use(x) where x (or what it names) is
mutable by another actor in the gap. Confirm: identify the shared thing, show a
writer that can change it between check and use.
Check-then-act on shared state without atomicity. "If not exists, create";
"if balance ≥ n, deduct n"; "if not already redeemed, redeem." Two requests
both pass the check before either acts → double-spend, duplicate creation,
coupon reuse. Confirm: two concurrent runs both read the pre-act value; neither
the read+act is atomic (no transaction, lock, SELECT … FOR UPDATE, compare-
and-swap, or unique constraint).
Unsynchronized shared mutable state. A field/map/counter read and written by multiple threads with no lock/atomic. Confirm: two threads reach the same memory, at least one writes, no happens-before relationship (no shared lock, no atomic, no ownership handoff) orders them.
Atomicity violation across a compound update. Several fields that must move together are updated without a single critical section, so a concurrent reader sees a torn, inconsistent state. Confirm: a reader path observes the fields mid-update.
Lock misuse. Right idea, wrong execution: the lock is taken after the shared access, a different lock guards read vs write, the lock is released early, or the critical section doesn't cover the whole check-then-act. Confirm: the guarded region doesn't actually span both the decision and the action.
Shared sinks are the anchors: process-global/static mutable state, singleton caches, ORM objects reused across requests, filesystem paths derived from a check, and any DB write preceded by an application-level read that decides it. For each, ask: who else touches this concurrently, and is the decision+action atomic?
Double-spend via check-then-act.
redeem(code):row = db.get(code); if row.used: reject; … ; row.used = True; db.save(row). Two requests with the samecodeboth readused == Falsebefore either saves. Witness: interleave R1.read, R2.read, R1.save, R2.save → both succeed. No transaction, noSELECT … FOR UPDATE, no unique/CAS onused. Confirmed atomicity/check-then-act race, severity high, impact = coupon/token reused N times. Remediation: atomic conditional update (UPDATE … SET used=true WHERE code=? AND used=false) and act on affected-row-count.
You need to identify shared state and the concurrent entry points that reach it,
then read the ordering around each access. A code property graph helps you find
every reader/writer of a shared object and every path into a check-then-act; a
concurrency-aware analyzer or a targeted stress/PoC harness corroborates a real
window. State each finding as an interleaving witness and emit per the
finding schema, with the two operation orders in
evidence and reachable = conditional on the interleaving.
auditing-guard-gaps - when only some paths take the lock/transaction.hunting-bugs-with-a-code-graph - the master loop that routes these here.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub unboundcompute/security-agent-skills --plugin security-agent-skills194 skills in this plugin
/adjudicating-dependency-cve-reachabilityDecide whether a CVE in a dependency actually exposes your application before you scramble to patch: is the vulnerable function on a real call path from your code, do the trigger preconditions hold, and can an attacker control the input that reaches it. Use when an advisory, SCA scan, or dependency bot flags a CVE and you must separate a genuine exposure from unreachable noise, or justify why you are or are not affected. Covers pinning the vulnerable symbol, call-path reachability, precondition checks, and taint from your entry points./adjudicating-taint-pathsDecide whether a whitebox lead is a real bug by tracing taint from an untrusted source to a dangerous sink and confirming every hop against live source. Use after a scanner, a candidate list, or your own reading surfaces a "this looks dangerous" sink (SQL exec, system/exec, file open, deserialize, template render, redirect target, memcpy) and you must decide whether attacker- controlled input actually reaches it - or kill the lead with evidence. Covers forward and reverse taint, witness paths, sanitizer analysis, and the evidence rules that separate a finding from a false positive.Other plugins' skills for the same job