Skip to content

sb-dev/openquant / .agents/skills/rust-review

rust-review

Verified

Review 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.

FileKindSize
SKILL.mdskill md5.4 KB
upstream/.claude-plugin/plugin.jsonconfig530 B
upstream/README.mdmarkdown8.2 KB
upstream/agents/rust-review-dedup-judge.mdmarkdown20.4 KB
upstream/agents/rust-review-fp-judge.mdmarkdown23.1 KB
upstream/agents/rust-review-worker.mdmarkdown31.8 KB
upstream/prompts/clusters/async-runtime.mdmarkdown855 B
upstream/prompts/clusters/concurrency-data-race.mdmarkdown2.6 KB
upstream/prompts/clusters/concurrency-locking.mdmarkdown6.9 KB
upstream/prompts/clusters/error-handling.mdmarkdown1.6 KB
upstream/prompts/clusters/ffi-cross-language.mdmarkdown3.3 KB
upstream/prompts/clusters/info-disclosure.mdmarkdown562 B
upstream/prompts/clusters/input-os-safety.mdmarkdown1.1 KB
upstream/prompts/clusters/layout-safety.mdmarkdown572 B
upstream/prompts/clusters/logic-correctness.mdmarkdown3.8 KB
upstream/prompts/clusters/manifest.jsonconfig10.9 KB
upstream/prompts/clusters/memory-safety.mdmarkdown4.6 KB
upstream/prompts/clusters/panic-dos.mdmarkdown6.0 KB
upstream/prompts/clusters/recursion-dos.mdmarkdown5.3 KB
upstream/prompts/clusters/resource-handling.mdmarkdown1.5 KB
upstream/prompts/clusters/static-hygiene.mdmarkdown746 B
upstream/prompts/clusters/unsafe-boundary.mdmarkdown15.6 KB
upstream/prompts/general/abi-mismatch-finder.mdmarkdown705 B
upstream/prompts/general/adversarial-trait-finder.mdmarkdown1.5 KB
upstream/prompts/general/arithmetic-overflow-finder.mdmarkdown2.1 KB
upstream/prompts/general/assertion-reachable-finder.mdmarkdown879 B
upstream/prompts/general/async-blocking-finder.mdmarkdown1.2 KB
upstream/prompts/general/atomic-race-finder.mdmarkdown1.3 KB
upstream/prompts/general/buffer-overflow-unsafe-finder.mdmarkdown2.6 KB
upstream/prompts/general/bufwriter-unflushed-finder.mdmarkdown995 B
upstream/prompts/general/cancel-safety-finder.mdmarkdown1.2 KB
upstream/prompts/general/cargo-lint-config-finder.mdmarkdown2.4 KB
upstream/prompts/general/closure-ffi-finder.mdmarkdown3.9 KB
upstream/prompts/general/closure-panic-finder.mdmarkdown1.1 KB
upstream/prompts/general/collection-key-mutation-finder.mdmarkdown1.9 KB
upstream/prompts/general/cstring-dangling-finder.mdmarkdown1.3 KB
upstream/prompts/general/deprecated-api-finder.mdmarkdown1.9 KB
upstream/prompts/general/destructor-skip-finder.mdmarkdown1.4 KB
upstream/prompts/general/double-free-finder.mdmarkdown1.6 KB
upstream/prompts/general/drop-panic-finder.mdmarkdown973 B
upstream/prompts/general/dyn-trait-ffi-finder.mdmarkdown2.8 KB
upstream/prompts/general/float-edge-finder.mdmarkdown798 B
upstream/prompts/general/foreign-drop-finder.mdmarkdown2.7 KB
upstream/prompts/general/invalid-free-finder.mdmarkdown1.2 KB
upstream/prompts/general/lossy-from-into-finder.mdmarkdown603 B
upstream/prompts/general/lossy-str-conversion-finder.mdmarkdown1.2 KB
upstream/prompts/general/msrv-mismatch-finder.mdmarkdown401 B
upstream/prompts/general/nondeterminism-finder.mdmarkdown1.6 KB
upstream/prompts/general/opaque-pointer-finder.mdmarkdown1.9 KB
upstream/prompts/general/ord-eq-hash-finder.mdmarkdown754 B
upstream/prompts/general/out-of-bounds-index-finder.mdmarkdown727 B
upstream/prompts/general/packed-field-ref-finder.mdmarkdown3.7 KB
upstream/prompts/general/panic-unwind-unsafe-finder.mdmarkdown3.0 KB
upstream/prompts/general/path-traversal-join-finder.mdmarkdown1.7 KB
upstream/prompts/general/pointer-exposure-finder.mdmarkdown1.8 KB
upstream/prompts/general/raw-fd-lifecycle-finder.mdmarkdown2.0 KB
upstream/prompts/general/recursive-deserialize-stack-overflow-finder.mdmarkdown4.8 KB
upstream/prompts/general/recursive-drop-stack-overflow-finder.mdmarkdown2.7 KB
upstream/prompts/general/recursive-format-stack-overflow-finder.mdmarkdown4.1 KB
upstream/prompts/general/refcell-borrow-panic-finder.mdmarkdown1.2 KB
upstream/prompts/general/repr-c-padding-finder.mdmarkdown2.2 KB
upstream/prompts/general/resource-exhaustion-finder.mdmarkdown2.4 KB
upstream/prompts/general/result-discarded-finder.mdmarkdown1.6 KB
upstream/prompts/general/select-bias-finder.mdmarkdown1.2 KB
upstream/prompts/general/send-sync-bounds-finder.mdmarkdown2.6 KB
upstream/prompts/general/serialize-struct-mismatch-finder.mdmarkdown2.3 KB
upstream/prompts/general/shared-memory-race-finder.mdmarkdown2.8 KB
upstream/prompts/general/static-mut-race-finder.mdmarkdown2.8 KB
upstream/prompts/general/str-slice-boundary-finder.mdmarkdown1.0 KB
upstream/prompts/general/string-comparison-finder.mdmarkdown1.4 KB
upstream/prompts/general/toctou-finder.mdmarkdown1.3 KB
upstream/prompts/general/uninitialized-read-finder.mdmarkdown1.8 KB
upstream/prompts/general/union-ub-finder.mdmarkdown3.5 KB
upstream/prompts/general/unsafe-sync-impl-finder.mdmarkdown3.7 KB
upstream/prompts/general/unwrap-on-untrusted-finder.mdmarkdown1.3 KB
upstream/prompts/general/use-after-free-finder.mdmarkdown2.9 KB
upstream/prompts/general/vec-set-len-uninit-finder.mdmarkdown2.5 KB
upstream/scripts/build_run_plan.pyscript24.0 KB
upstream/scripts/generate_sarif.pyexecutablescript22.9 KB
upstream/scripts/pyproject.tomlmanifest220 B
upstream/scripts/test_gating.pyscript12.6 KB
upstream/scripts/test_generate_sarif.pyscript19.5 KB
upstream/scripts/test_prompt_regexes.pyscript4.3 KB
upstream/scripts/test_split.pyscript10.2 KB
upstream/scripts/test_validate_artifacts.pyscript10.3 KB
upstream/scripts/validate_artifacts.pyscript11.4 KB
upstream/skills/rust-review/SKILL.upstream.mdmarkdown43.5 KB

upstream/prompts/general/recursive-deserialize-stack-overflow-finder.md

View on GitHub
---
name: recursive-deserialize-stack-overflow-finder
description: Detects deserialization of untrusted input into recursive types without an enforced depth limit (bincode/postcard/custom Deserialize, or a codec like serde_json/serde_yaml/toml/ron/ciborium with its default recursion limit raised or bypassed)
---

**Finding ID Prefix:** `RECURSEDES`.

**Gates:**

1. A deserialize entry point reads from an untrusted source:
   - `serde_json::{from_str,from_slice,from_reader,from_value}`
   - `serde_yaml::{from_str,from_slice,from_reader}`
   - `toml::from_str` / `toml::from_slice`
   - `ron::{from_str,de::from_reader}`
   - `ciborium::de::from_reader`, `bincode::deserialize`, `postcard::from_bytes`
   - `#[derive(Deserialize)]` types reached via `axum::Json`, `actix_web::web::Json`, `rocket::serde::json::Json`, `warp::body::json`, gRPC `prost` decode, etc.
2. The target type is recursive (in `rec_map` from Phase A), or is a library recursive type (`serde_json::Value`, `serde_yaml::Value`, `toml::Value`, `ron::Value`, `ciborium::Value`, `syn::*`).
3. No depth-limiting wrapper is in effect on this call site:
   - **`serde_json`** enforces a 128-frame limit by default — usually safe. Flag **only** if `Deserializer::disable_recursion_limit()` is called, or if a custom impl re-drives parsing *outside* the serde `Deserializer` (e.g. it captures raw bytes and calls `from_str`/`from_slice` again, or hand-rolls its own parser). An ordinary recursive `Visitor`/`Deserialize` that recurses through the normal serde API (`next_element`/`next_value`) is **still capped at 128** by the Deserializer — do **not** flag it on that basis alone.
   - **`serde_yaml`** (128), **`toml`** (~80 via `toml_edit`), **`ron`** (128), and **`ciborium`** (256) all enforce a built-in recursion limit by default during deserialization — usually safe, like `serde_json`. Flag them **only** if that limit is explicitly raised/disabled (e.g. `ron::Options::without_recursion_limit`, `toml`'s `unbounded` feature) or a custom out-of-band parser bypasses the codec. Only **`bincode`** and **`postcard`** genuinely impose **no** default depth limit — for those, any deserialize of untrusted bytes into a recursive type is a finding unless an explicit pre-parse depth check or `serde_stacker` is in place.
   - For HTTP frameworks, `axum::Json` and friends delegate to the underlying codec — they inherit its limit (or lack of one).
4. The call is reachable from an external trust boundary (request, file, env, IPC), not a constant.

**Why it matters:** the deserializer walks input depth recursively. At ~5–10 KB of stack per frame and a typical 8 MB main-thread stack on Linux (often 2 MB on async worker threads), an attacker submitting a few hundred to a few thousand levels of nested `[[[...]]]` or `{"a":{"a":{...}}}` crashes the worker. The crash is an *abort*, not a panic — `catch_unwind` does not help. A built-in parse cap is the **norm**, not the exception (`serde_json` 128, `serde_yaml` 128, `toml` ~80, `ron` 128, `ciborium` 256); `bincode` and `postcard` are the codecs that leave depth to the caller.

This finder bounds what depths the later `RECURSEFMT` and `RECURSEDROP` finders need to consider. Run it first.

**FPs (reject):**

- `serde_json` codec, target type uses derived `Deserialize` only, no `disable_recursion_limit()` — the 128-frame cap applies.
- A pre-parse step explicitly bounds depth (length-prefix scan, structural tokenizer that refuses depth > N, `tokio_util::codec` with a depth-aware framer).
- The deserializer is wrapped in `serde_stacker::Deserializer`, which grows frames on the heap instead of the stack.
- Input source is statically trusted (config file shipped with the binary, `include_str!`, build script).
- `serde_yaml`/`toml`/`ron`/`ciborium` with **default** options — these enforce built-in recursion caps (128 / ~80 / 128 / 256). Treat as safe unless the cap is raised/disabled (`without_recursion_limit`, the `unbounded` feature, etc.) or bypassed by a custom parser.

**Patch:**

- For `bincode`/`postcard` (no default cap), or any codec whose limit was raised/disabled: wrap the deserializer in `serde_stacker::Deserializer`, OR pre-scan the input for maximum nesting depth and refuse > N (N typically 32–128 depending on protocol). For `serde_yaml`/`toml`/`ron`/`ciborium`, simply keep their default recursion limit (do not call `without_recursion_limit` / enable `unbounded`).
- For custom `Deserialize`/`Visitor` impls that recurse: thread a depth counter through `DeserializeSeed` and `Visitor::visit_*`, returning `Err(de::Error::custom("max depth"))` past the cap.
- For HTTP framework extractors, attach a body-size limit *and* a depth limit — body size alone does not bound depth (`[[[[...]]]]` is dense).
- Do **not** rely on `serde_json::Deserializer::disable_recursion_limit()` "just for performance" — removing the cap re-introduces the bug on the JSON codec too.
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: 470kUpdated Claude CodeCodexVerifiedInstall
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: 470kUpdated Claude CodeCodexVerifiedInstall
rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics.Stars: 470kUpdated Claude CodeCodexVerifiedInstall
ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first.Stars: 194kUpdated Claude CodeCodexVerifiedInstall