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/invalid-free-finder.md
View on GitHub---
name: invalid-free-finder
description: Detects invalid-free via assignment to dereferenced pointer over uninitialized memory
---
**Finding ID Prefix:** `INVFREE`.
**Bug shape (from research):** `alloc()` returns uninitialized memory. Writing `*ptr = new_val` invokes `Drop` on the **previous** (garbage) value to prevent leaks. The previous value is uninitialized bytes — Rust calls `Drop` on random memory.
**Verification gates:**
1. **Uninit allocation:** `ptr` originates from raw `alloc`, `MaybeUninit::uninit().as_mut_ptr()`, or similar.
2. **Assignment via deref:** `*ptr = expr` syntax (NOT `ptr::write(ptr, expr)`).
3. **Drop type:** the value type has a non-trivial `Drop`.
4. **No prior init:** no `ptr::write` or analogous initialization preceded the assignment on this control-flow path.
**FPs to reject:**
- Uses `ptr::write` (correct primitive — overwrites without Drop on previous value).
- Type is `Copy` and has no Drop.
- `MaybeUninit::write` (explicitly handles this).
**Search patterns:**
```
alloc::alloc\s*\(|MaybeUninit::uninit\(\)
\*\s*[\w.]+\s*(\([^)]*\))?\s*=[^=]
ptr::write\b
```
**Patch:** replace `*ptr = val` with `ptr::write(ptr, val)`.
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 |