Install any skill in seconds. Free to start, no credit card required.
Get Started Free →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.
.claude/skills/trailofbits-substrate-vulnerability-scanner/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-05 | ✗→✓ | ▲ Improved | 594% | 0% |
| case-10 | ✗→✓ | ▲ Improved | 83% | 0% |
| case-18 | ✗→✓ | ▲ Improved | 61% | 0% |
| case-20 | ✗→✓ | ▲ Improved | 93% | 0% |
| case-21 | ✗→✓ | ▲ Improved | 95% | 0% |
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.
.rsrust// Substrate/FRAME indicators #[pallet] pub mod pallet { use frame_support::pallet_prelude::*; use frame_system::pallet_prelude::*; #[pallet::config] pub trait Config: frame_system::Config { } #[pallet::call] impl<T: Config> Pallet<T> { #[pallet::weight(10_000)] pub fn example_function(origin: OriginFor<T>) -> DispatchResult { } } } // Common patterns DispatchResult, DispatchError ensure!, ensure_signed, ensure_root StorageValue, StorageMap, StorageDoubleMap #[pallet::storage] #[pallet::call] #[pallet::weight] #[pallet::validate_unsigned]
pallets/*/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.
+, -, *, / operators wrap in release modechecked_* or saturating_* methodsunwrap(), expect(), array indexing without bounds checkensure!#[transactional]pallet_randomness_collective_flip vulnerable to collusionpallet_babe::RandomnessFromOneEpochAgo)random(subject) not random_seed()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:
bash# Search for panic-prone patterns rg "unwrap\(\)" pallets/ rg "expect\(" pallets/ rg "\[.*\]" pallets/ # Array indexing rg " as u\d+" pallets/ # Type casts rg "\.unwrap_or" pallets/
bash# Find direct arithmetic rg " \+ |\+=| - |-=| \* |\*=| / |/=" pallets/ # Should find checked/saturating alternatives instead rg "checked_add|checked_sub|checked_mul|checked_div" pallets/ rg "saturating_add|saturating_sub|saturating_mul" pallets/
cargo test --features runtime-benchmarksbash# Find privileged operations rg "ensure_signed" pallets/ | grep -E "pause|emergency|admin|force|sudo" # Should use ensure_root or custom origins rg "ensure_root|ForceOrigin|AdminOrigin" pallets/
rust// Use test-fuzz for property-based testing #[cfg(test)] mod tests { use test_fuzz::test_fuzz; #[test_fuzz] fn fuzz_transfer(from: AccountId, to: AccountId, amount: u128) { // Should never panic let _ = Pallet::transfer(from, to, amount); } #[test_fuzz] fn fuzz_no_panics(call: Call) { // No dispatchable should panic let _ = call.dispatch(origin); } }
bash# Run benchmarks to generate weights cargo build --release --features runtime-benchmarks ./target/release/node benchmark pallet \ --chain dev \ --pallet pallet_example \ --extrinsic "*" \ --steps 50 \ --repeat 20
bash# Test runtime upgrades cargo build --release --features try-runtime try-runtime --runtime ./target/release/wbuild/runtime.wasm \ on-runtime-upgrade live --uri wss://rpc.polkadot.io
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:
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-08 | pass→pass | 10,112 | 8,124 | -20% | 1 | 1 | 0% | 1,862 | 4,027 | +116% | 0 | 0 | — |
case-01 | fail→fail | 9,194 | 7,567 | -18% | 1 | 1 | 0% | 806 | 3,306 | +310% | 0 | 0 | — |
case-02 | fail→fail | 12,576 | 10,396 | -17% | 1 | 1 | 0% | 1,285 | 3,501 | +172% | 0 | 0 | — |
case-03 | fail→fail | 8,982 | 14,958 | +67% | 1 | 1 | 0% | 1,095 | 3,361 | +207% | 0 | 0 | — |
case-04 | fail→fail | 12,122 | 11,406 | -6% | 1 | 1 | 0% | 1,159 | 3,362 | +190% | 0 | 0 | — |
case-05 | fail→pass | 4,762 | 17,779 | +273% | 1 | 1 | 0% | 864 | 5,995 | +594% | 0 | 0 | — |
case-06 | fail→fail | 16,566 | 15,275 | -8% | 1 | 1 | 0% | 3,126 | 5,273 | +69% | 0 | 0 | — |
case-07 | pass→pass | 12,438 | 7,732 | -38% | 1 | 1 | 0% | 2,158 | 3,900 | +81% | 0 | 0 | — |
case-09 | pass→pass | 12,460 | 10,759 | -14% | 1 | 1 | 0% | 2,197 | 4,375 | +99% | 0 | 0 | — |
case-10 | fail→pass | 12,443 | 7,260 | -42% | 1 | 1 | 0% | 2,190 | 4,015 | +83% | 0 | 0 | — |
case-11 | pass→pass | 15,434 | 13,775 | -11% | 1 | 1 | 0% | 3,000 | 4,936 | +65% | 0 | 0 | — |
case-12 | pass→pass | 12,509 | 10,912 | -13% | 1 | 1 | 0% | 2,002 | 4,425 | +121% | 0 | 0 | — |
case-13 | pass→pass | 9,566 | 6,688 | -30% | 1 | 1 | 0% | 1,936 | 3,808 | +97% | 0 | 0 | — |
case-14 | pass→pass | 17,181 | 7,533 | -56% | 1 | 1 | 0% | 3,151 | 3,774 | +20% | 0 | 0 | — |
case-15 | pass→pass | 6,401 | 4,284 | -33% | 1 | 1 | 0% | 1,324 | 3,160 | +139% | 0 | 0 | — |
case-16 | pass→pass | 14,241 | 12,037 | -15% | 1 | 1 | 0% | 2,684 | 4,694 | +75% | 0 | 0 | — |
case-17 | pass→pass | 15,250 | 13,094 | -14% | 1 | 1 | 0% | 2,713 | 5,125 | +89% | 0 | 0 | — |
case-18 | fail→pass | 13,304 | 5,693 | -57% | 1 | 1 | 0% | 2,162 | 3,479 | +61% | 0 | 0 | — |
case-19 | pass→pass | 6,154 | 4,819 | -22% | 1 | 1 | 0% | 1,074 | 3,413 | +218% | 0 | 0 | — |
case-20 | fail→pass | 10,813 | 6,236 | -42% | 1 | 1 | 0% | 1,876 | 3,618 | +93% | 0 | 0 | — |
case-21 | fail→pass | 10,320 | 8,821 | -15% | 1 | 1 | 0% | 2,133 | 4,162 | +95% | 0 | 0 | — |
case-22 | pass→pass | 6,535 | 5,743 | -12% | 1 | 1 | 0% | 1,215 | 3,568 | +194% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +23 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.