npx skills add ...
npx skills add trailofbits/skills --skill substrate-vulnerability-scanner
Scans Substrate/Polkadot pallets for 7 critical vulnerabilities including arithmetic overflow, panic DoS, incorrect weights, and bad origin checks. Use when auditing Substrate runtimes or FRAME pallets.
npx skills add trailofbits/skills --skill substrate-vulnerability-scanner
Systematically scan Substrate runtime modules (pallets) for platform-specific security vulnerabilities that can cause node crashes, DoS attacks, or unauthorized access. This skill encodes 7 critical vulnerability patterns unique to Substrate/FRAME-based chains.
.rspallets/*/lib.rs - Pallet implementationsruntime/lib.rs - Runtime configurationbenchmarking.rs - Weight benchmarksCargo.toml with frame-* dependenciesWhen invoked, I will:
I check for 7 critical vulnerability patterns unique to Substrate/FRAME. For detailed detection patterns, code examples, mitigations, and testing strategies, see VULNERABILITY_PATTERNS.md.
Arithmetic Overflow ⚠️ CRITICAL
+, -, *, / operators wrap in release modechecked_* or saturating_* methodsDon't Panic ⚠️ CRITICAL - DoS
unwrap(), expect(), array indexing without bounds checkensure!Weights and Fees ⚠️ CRITICAL - DoS
Verify First, Write Last ⚠️ HIGH (Pre-v0.9.25)
#[transactional]Unsigned Transaction Validation ⚠️ HIGH
Bad Randomness ⚠️ MEDIUM
pallet_randomness_collective_flip vulnerable to collusionpallet_babe::RandomnessFromOneEpochAgo)random(subject) not random_seed()Bad Origin ⚠️ CRITICAL
ensure_signed allows any user for privileged operationsensure_root or custom origins (ForceOrigin, AdminOrigin)For complete vulnerability patterns with code examples, see VULNERABILITY_PATTERNS.md.
pallets/*/lib.rs)runtime/lib.rs)For each #[pallet::call] function:
cargo test --features runtime-benchmarksReport on every pattern in §5, whether or not it turned anything up. This skill has no Finding Template, so the table opens the report and the findings follow it, with all 7 rows present:
| # | Pattern | Verdict | Evidence |
|---|---|---|---|
| 1 | Arithmetic Overflow | found | src/lib.rs:212 -- + on BalanceOf<T> in do_transfer |
| 2 | Don't Panic | ||
| 3 | Weights and Fees | ||
| 4 | Verify First, Write Last | ||
| 5 | Unsigned Transaction Validation | ||
| 6 | Bad Randomness | ||
| 7 | Bad Origin |
Each verdict is one of:
found — cite file:line and write the finding up in full after the table.clear — the pattern applies to this pallet and the pallet handles it. Name the macro, origin check, or
arithmetic method you searched for, so a reader can repeat the search.n/a — the pattern cannot apply here. Give the reason in one clause ("this pallet accepts no unsigned
transactions"). Not having looked is not n/a. Note that pattern 4 is version-scoped (pre-v0.9.25): say
which runtime version the pallet targets rather than dropping the row.A table with fewer than 7 rows is an incomplete scan and must be reported as one. A row whose Verdict cell is empty is incomplete in the same way: row 1 above is filled in to show the shape, and every row is filled in the same way before the report is done. Seven clear verdicts is a
result a reader can act on. A report that covers three patterns and says nothing about the other four reads
exactly like a clean pallet, and that is the failure this table exists to prevent.
building-secure-contracts/not-so-smart-contracts/substrate/Before completing Substrate pallet audit:
Arithmetic Safety (CRITICAL):
+, -, *, / operators in dispatchableschecked_* or saturating_*try_into() with error handlingPanic Prevention (CRITICAL):
unwrap() or expect() in dispatchablesensure!Weights & DoS (CRITICAL):
Access Control (CRITICAL):
ensure_root or custom originsensure_signed only for user-level operationsStorage Safety (HIGH):
#[transactional]Other (MEDIUM):
random(subject) not random_seed()Testing:
found, clear or n/a with a reasonn/a costs one
clause and makes the judgment reviewable. Silence records nothing, and a reader cannot tell it apart from
not having checked.+ on a
Balance is pattern 1 whether or not the compiler said anything, and debug assertions do not run on a
production node.ensure_signed is an origin check." It establishes that someone signed, not that the right someone
did. Pattern 7 is about which origin is required, and ensure_signed where ensure_root belongs passes
this rationalization while failing the check.