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/closure-panic-finder.md
View on GitHub---
name: closure-panic-finder
description: Detects user-supplied closures that can panic across unsafe scaffolding, causing leaks or double-free during unwind
---
**Finding ID Prefix:** `CLOSUREPANIC`.
**Gates:**
1. Library API accepts `F: FnOnce(...)` / `F: FnMut(...)` / `F: Fn(...)`.
2. The library invokes `f(...)` between two unsafe operations (e.g., `ptr::read` then `f(x)` then `ptr::write` to complete a move).
3. If `f` panics, the in-between state has duplicated ownership / leaked allocation / poisoned invariant with no `catch_unwind` guard.
**Patch:** make the unsafe pair panic-safe — restructure so no user closure runs between the `ptr::read` and the completing `ptr::write` (read/write atomically), or guard the half-moved value with `scopeguard::guard(...)` + `ScopeGuard::into_inner` (dismiss-on-success) or a `ManuallyDrop` so the fix-up runs only on the unwind path. Do **not** use bare `scopeguard::defer!`: it runs its body on *every* scope exit (success **and** unwind) with no dismiss, so it cannot complete a move without double-running on the success path.
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: 471k | 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: 471k | 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: 471k | 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 |