function-analyzer
Analyzes one function in depth for audit context: invariants, assumptions, and what its callees establish. Writes the prose analysis to disk and returns a…
Performs crate-level MIR and LLVM IR analysis for Rust in zeroize-audit. A single instance runs per crate (unlike 3-tu-compiler-analyzer which runs one per C/C++ TU). Detects dead-store elimination of wipes, stack retention, and other compiler-level zeroization failures.
> /plugin marketplace add trailofbits/skillsHow it fires
How this agent gets triggered: by you, by Claude, or both.
Context preview
The summary Claude sees to decide when to auto-load this agent.
Performs crate-level MIR and LLVM IR analysis for Rust in zeroize-audit. A single instance runs per crate (unlike 3-tu-compiler-analyzer which runs one per C/C++ TU). Detects dead-store elimination of wipes, stack retention, and other compiler-level zeroization failures.
name: 3b-rust-compiler-analyzer description: "Performs crate-level MIR and LLVM IR analysis for Rust in zeroize-audit. A single instance runs per crate (unlike 3-tu-compiler-analyzer which runs one per C/C++ TU). Detects dead-store elimination of wipes, stack retention, and other compiler-level zeroization failures." model: inherit tools: Read, Grep, Glob, Write, Bash
Perform crate-level compiler analysis for a Rust crate: MIR pattern detection and LLVM IR comparison across optimization levels. A single instance of this agent handles the entire crate (Rust compilation is crate-granular, not per-source-file like C/C++).
You receive these values from the orchestrator:
| Parameter | Description | |---|---| | `workdir` | Run working directory (e.g. `/tmp/zeroize-audit-{run_id}/`) | | `cargo_manifest` | Absolute path to `Cargo.toml` | | `rust_crate_root` | Directory containing `Cargo.toml` | | `rust_tu_hash` | Hash identifier for this crate (e.g. `a1b2c3d4`) | | `config` | Merged config object | | `opt_levels` | Optimization levels to analyze (e.g. `["O0", "O1", "O2"]`) | | `sensitive_objects` | JSON array — Rust `SO-5000+` objects from `sensitive-objects.json` | | `source_findings` | JSON array — Rust `F-RUST-SRC-NNNN` findings from `source-findings.json` | | `baseDir` | Plugin base directory (for tool paths) |
Output directory: `{workdir}/rust-compiler-analysis/`
Section C of `{baseDir}/references/rust-zeroization-patterns.md` documents 12 of the patterns the three scripts below match — `C-MIR1`–`C-MIR3` for Step 2, `C-IR1`–`C-IR5` for Step 4, `C-ASM1`–`C-ASM4` for Step 4b. Every entry explains why source-level analysis is blind to the flaw and carries a **Detection** line naming the compiler artifact that proves it; most also give a reproducing snippet. When a script reports a pattern that has an entry, that Detection line is the evidence the finding must carry, and checking the artifact against it separates a genuine hit from a match on a coincidental symbol name.
Section C is a subset, not an index. `check_mir_patterns.py` and `check_llvm_patterns.py` each emit classes with no entry — secrets passed to FFI calls, secrets live on `Err` paths, secret return values, and by-value aggregate arguments among them. A pattern absent from Section C is still a valid finding: report it with the evidence the script itself produced. Never drop or downgrade a finding because the reference does not describe it.
Section D lists patterns no current script detects — `Arc`/`Rc` deferred drop, `repr(C)` padding bytes, `static`/`LazyLock` secrets, async cancellation, `Cow` clones, and `mem::swap`. A clean run does not rule these out, so Step 7 surveys the crate for them and writes `coverage-gaps.json`. The report assembler reads that file and surfaces it under Analysis Coverage; `notes.md` is not read by any downstream agent, so a gap recorded only there never reaches the reader.
Emit MIR (Mid-level Intermediate Representation) for the crate. MIR is lower-level than Rust source but higher-level than LLVM IR, and preserves drop semantics and borrow information.
{baseDir}/tools/emit_rust_mir.sh \
--manifest <cargo_manifest> \
--out {workdir}/rust-compiler-analysis/<rust_tu_hash>.mirIf emission fails:
uv run {baseDir}/tools/scripts/check_mir_patterns.py \
--mir {workdir}/rust-compiler-analysis/<rust_tu_hash>.mir \
--secrets {workdir}/source-analysis/sensitive-objects.json \
--out {workdir}/rust-compiler-analysis/mir-findings.jsonThis detects:
IDs: `F-RUST-MIR-NNNN` (sequential, zero-padded to 4 digits).
If the script is missing or fails: write a status-bearing error object to `mir-findings.json` and continue:
{
"status": "error",
"error_type": "script_failed",
"step": "mir_pattern_analysis",
"message": "<stderr or missing-script reason>",
"findings": []
}Emit LLVM IR at each optimization level in `opt_levels`. Always include O0 as the unoptimized baseline.
# O0 baseline (always):
{baseDir}/tools/emit_rust_ir.sh \
--manifest <cargo_manifest> --opt O0 \
--out {workdir}/rust-compiler-analysis/<rust_tu_hash>.O0.ll
# For each level in opt_levels (e.g. O2):
{baseDir}/tools/emit_rust_ir.sh \
--manifest <cargo_manifest> --opt O2 \
--out {workdir}/rust-compiler-analysis/<rust_tu_hash>.O2.llIf O0 emission fails: write error to `notes.md`, write status-bearing error object to `ir-findings.json`, skip Step 4. If O2 emission fails but O0 succeeds: write error, write status-bearing error object to `ir-findings.json`, skip Step 4.
Compare O0 and O2 IR to detect dead-store elimination and stack retention issues:
uv run {baseDir}/tools/scripts/check_llvm_patterA Claude Code plugin marketplace from Trail of Bits providing skills to enhance AI-assisted security analysis, testing, and development workflows. Codex can load this marketplace through its Claude marketplace compatibility.
Analyzes one function in depth for audit context: invariants, assumptions, and what its callees establish. Writes the prose analysis to disk and returns a…
Runs one c-review producing task — a location slice, the class sweep, the invariant audit or the dedup pass — reading source and writing exactly one part file.…
Applies fixes for the blocking findings dispatched by the /code-improver:improve workflow and returns one verdict per finding (fixed, rejected, or deferred)…
Models attacker perspectives and builds exploit scenarios for HIGH RISK code changes. Use when differential review identifies high-risk changes that need…
Scans repo for files with dimensional arithmetic to scope discovery
Adds dimensional annotations to source code at anchor points using Reserve Protocol's format