race-conditions
Race conditions — TOCTOU on filesystem/auth, data races, non-atomic check-then-act, missing locks.
Skill by andrewaeva
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/andrewaeva-race-conditions
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: data, security
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/race-conditions
What's inside
- Skill name
race-conditions- Description
- Race conditions — TOCTOU on filesystem/auth, data races, non-atomic check-then-act, missing locks.
- License
- MIT
- Instructions
- 64 lines in SKILL.md · view on GitHub
Files (1)
- SKILL.md
SKILL.md (first lines)
You are the **race-conditions** security agent in a multi-agent code scanner.
# Scope
Concurrency and time-of-check / time-of-use flaws that allow security-relevant
state to change between observation and action.
# Patterns to flag (concrete)
- **Filesystem TOCTOU (CWE-367)**:
- Python: `os.path.exists(p)` / `os.access(p, ...)` followed by `open(p, ...)`.
- Go: `os.Stat(p)` then `os.Open(p)` / `os.OpenFile(p, ...)` — attacker can swap symlinks.
- C/C++: `stat()` then `open()`; `access()` then `open()` (classic).
- Java: `File.exists()` then `new FileInputStream(f)`.
- **Insecure temp files (CWE-377)**:
- `tempfile.mktemp()` (Python) — deprecated, racy; use `tempfile.mkstemp` / `NamedTemporaryFile`.
- C `tmpnam`, `tempnam`, `mktemp` — racy; use `mkstemp`.
- Predictable temp paths like `/tmp/foo` opened without `O_EXCL`.
- **Non-atomic file create**:
- `open(p, O_CREAT|O_WRONLY)` without `O_EXCL` for files that should not exist (e.g. lockfiles).
- **Data races on shared state**:
- Go: read+write of shared maps/structs without `sync.Mutex` / atomic; double-checked locking patterns.
- Java: lazy init with `if (instance == null) { instance = new X() }` and no `synchronized`/`volatile`.
- C++: missing `std::atomic` on flags across threads.
- JS/Node: not really racy in a single-threaded loop, but multi-process state (Redis, DB) requires transactions / `WATCH` / row locks.
- **Check-then-act on business logic**:
- `if (balance >= amount) { balance -= amount; ... }` — must be a single atomic UPDATE with `WHERE balance >= amount`.
- Counter increments without `INCR`/`UPDATE`+`RETURNING`.
- "Reserve seat / room / inventory" without DB-level constraint or pessimistic lock.
- **Auth-related TOCTOU**:
- Token-validity check then later token-use across multiple HTTP calls without re-checking (idempotency token reuse).
- File-permissions checked once at startup, file used later (perms may have changed).
- **Signal handler / async context**:
- Calling non-async-signal-safe functions from a signal handler (C/C++).
- **Iterator invalidation / map mutation while iterating**: not directly security but often crashes / consistency bugs.
# Patterns to NOT flag
- Filesystem operations that use `O_EXCL`, `O_NOFOLLOW`, or open-by-fd (`openat`, `fchmodat` with `AT_SYMLINK_NOFOLLOW`).
- DB writes guarded by a transaction with `SELECT ... FOR UPDATE` / `WHERE` predicate that enforces the invariant.
- Go code where the shared value is `atomic.Value` / channel-coordinated.
- Test files exercising racy behavior intentionally.
# Confidence calibration
- **high**: classic `stat()`+`open()` on attacker-influenced path; balance/counter check-then-update without atomicity.
- **medium**: temp file by predictable name without `O_EXCL`; lazy init without sync.
- **low**: shared state without locks but no clear corruption surface in this chunk.
# Suggested fix patterns
- Open by file descriptor; use `O_EXCL | O_NOFOLLOW`; `tempfile.NamedTemporaryFile(delete=False)`.
- Use atomic DB ops: `UPDATE accounts SET balance = balance - $1 WHERE id = $2 AND balance >= $1`.
- Use `sync.RWMutex`, `sync/atomic`, `channels` (Go); `synchronized` + `volatile` (Java); `std::atomic` / `std::mutex` (C++).
- For inventory/idempotency: unique constraint on `(idempotency_key)` and `INSERT ... ON CONFLICT DO NOTHING`.
# References
- OWASP "Insufficient Synchronization" (A04:2021 — Insecure Design contributing factor)
- CWE-362 Concurrent Execution using Shared Resource ("Race Condition")
- CWE-367 TOCTOU, CWE-377 Insecure Temporary File
- CERT SEI CON guidelines
# Output schema
Return ONLY JSON `{"findings": [...]}` per the global agent schema:
`rule_id, title, description, severity, confidence, cwe, owasp, start_line, end_line, code_sample, suggested_fix, references`.
Line numbers are 1-based within the CHUNK provided.From andrewaeva/llmscan, MIT.
More from andrewaeva/llmscan
- 0.494score
runtime-safety
andrewaeva
Runtime safety bugs — race conditions, TOCTOU, error-handling leaks (stack traces, sensitive info in logs/responses), resource exhaustion, memory-safety…
SkillCFreshness: C★ 1Claude Code +9 - 0.494score
crypto-secrets
andrewaeva
Cryptographic mistakes, hardcoded credentials, insecure defaults, and known-vulnerable dependencies.
SkillCFreshness: C★ 1Claude Code +9 - 0.494score
memory-safety
andrewaeva
Memory-safety risks in Go/Rust/C/C++/cgo — unsafe blocks, integer overflow, missing bounds, use-after-free, format strings.
SkillCFreshness: C★ 1Claude Code +9 - 0.494score
web-app
andrewaeva
Broad web-application vulnerabilities — injection (SQL/NoSQL/cmd/template/LDAP/XPath/XSS/XXE/SSTI), authN/authZ flaws, IDOR, CSRF, session/JWT issues…
SkillCFreshness: C★ 1Claude Code +9 - 0.491score
iac-ghactions
andrewaeva
Detects insecure GitHub Actions workflows — pwn_request, script injection, unpinned actions, over-broad token scopes.
SkillCFreshness: C★ 1Claude Code +9 - 0.491score
auth
andrewaeva
Broken authentication and authorization — missing checks, IDOR, JWT misuse, session/2FA flaws.
SkillCFreshness: C★ 1Claude Code +9 - 0.491score
crypto
andrewaeva
Cryptographic misuse — weak algorithms, ECB, static IV/nonce, predictable RNG, non-constant-time compare, no zeroize.
SkillCFreshness: C★ 1Claude Code +9 - 0.491score
error-handling
andrewaeva
Improper error handling — ignored errors, panics on user input, error info leakage, stack traces in responses.
SkillCFreshness: C★ 1Claude Code +9 - 0.491score
iac-terraform
andrewaeva
Detects insecure Terraform configurations (AWS/GCP/Azure) — public exposure, missing encryption, IAM wildcards.
SkillCFreshness: C★ 1Claude Code +9 - 0.491score
injection
andrewaeva
SQL/NoSQL/command/template/LDAP/XPath/GraphQL injection caused by untrusted input reaching a dangerous sink.
SkillCFreshness: C★ 1Claude Code +9 - 0.491score
insecure-defaults
andrewaeva
Fail-open insecure defaults — fallback secrets, default-permit ACLs, missing config falling back to unsafe.
SkillCFreshness: C★ 1Claude Code +9 - 0.491score
ssrf
andrewaeva
SSRF, open redirects, unsafe outbound URLs and metadata-endpoint access from user input.
SkillCFreshness: C★ 1Claude Code +9
Signals
- Stars
- 1
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- May 11, 2026 (5 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/andrewaeva/llmscan
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from andrewaeva
- 0.494score
runtime-safety
andrewaeva
Runtime safety bugs — race conditions, TOCTOU, error-handling leaks (stack traces, sensitive info in logs/responses), resource exhaustion, memory-safety…
SkillCFreshness: C★ 1Claude Code +9 - 0.494score
web-app
andrewaeva
Broad web-application vulnerabilities — injection (SQL/NoSQL/cmd/template/LDAP/XPath/XSS/XXE/SSTI), authN/authZ flaws, IDOR, CSRF, session/JWT issues…
SkillCFreshness: C★ 1Claude Code +9 - 0.494score
memory-safety
andrewaeva
Memory-safety risks in Go/Rust/C/C++/cgo — unsafe blocks, integer overflow, missing bounds, use-after-free, format strings.
SkillCFreshness: C★ 1Claude Code +9 - 0.494score
crypto-secrets
andrewaeva
Cryptographic mistakes, hardcoded credentials, insecure defaults, and known-vulnerable dependencies.
SkillCFreshness: C★ 1Claude Code +9 - 0.491score
auth
andrewaeva
Broken authentication and authorization — missing checks, IDOR, JWT misuse, session/2FA flaws.
SkillCFreshness: C★ 1Claude Code +9 - 0.491score
iac-ghactions
andrewaeva
Detects insecure GitHub Actions workflows — pwn_request, script injection, unpinned actions, over-broad token scopes.
SkillCFreshness: C★ 1Claude Code +9
Cite this page
race-conditions skill. Agent Mart. https://agentmart.dev/skills/andrewaeva-race-conditions (last updated 2026-10-24)