sb-dev/openquant / .agents/skills/rust-review
rust-review
VerifiedReview Rust crates, services, or libraries for safe/unsafe boundary issues, memory safety, concurrency hazards, panic-induced denial of service, FFI safety, and async runtime mistakes. Use for a Rust security audit, especially unsafe, FFI, or concurrent code.
upstream/prompts/general/toctou-finder.md
View on GitHub---
name: toctou-finder
description: Detects filesystem time-of-check/time-of-use races where a path check is separated from the matching open/create/remove
---
**Finding ID Prefix:** `TOCTOU`.
**Bug shape:** A check (`exists`, `metadata`, `symlink_metadata`, permission or owner test) followed by a separate use (`File::open`, `create`, `remove_file`) on the same path leaves a window in which an attacker can swap the target (e.g., substitute a symlink) so the use operates on a different object than the check validated.
**Gates:**
1. A check call and a later use call reference the same path variable or expression.
2. The check's result gates a security decision (access control, content trust, creation safety).
3. The operation is non-atomic: separate syscalls with no `O_EXCL`/`create_new`, and no fd-relative reuse (open once then `fstat` on the resulting fd).
**FPs:**
- Atomic primitive used: `OpenOptions::create_new` / `O_EXCL`, or open-then-`fstat`/metadata on the returned fd.
- No security decision rides on the check result.
- Path is under the process's exclusive control (mode-0700 tmpdir, no other writers).
**Patch:** open the file once and call `fstat`/`metadata` on the returned fd, or use `OpenOptions::create_new` for creation; avoid re-checking the path name after the initial open.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |