substrate-vulnerability-scanner

Scans Substrate FRAME pallets for seven critical vulnerability patterns including overflow, panic DoS, and bad origins.

Updated Mar 22, 2026
One-click install
npx skills add https://github.com/TECH-HY/SKILLS --skill substrate-vulnerability-scanner-tech-hy
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: substrate-vulnerability-scanner
Source: https://github.com/TECH-HY/SKILLS/tree/main/skills/substrate-vulnerability-scanner
Command: npx skills add https://github.com/TECH-HY/SKILLS --skill substrate-vulnerability-scanner-tech-hy

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Auditing Substrate/Polkadot runtime pallets for security flaws is error-prone and requires deep knowledge of FRAME-specific pitfalls like silent arithmetic overflow, panic-induced node crashes, and misconfigured origins. This Skill systematizes that audit by checking every dispatchable against 7 known critical vulnerability patterns. ## Core Features & Use Cases - Seven Vulnerability Patterns: Detects arithmetic overflow, panic DoS, incorrect weights and fees, verify-first violations, unsigned transaction validation flaws, bad randomness, and bad origin checks. - Structured Scanning Workflow: Guides platform detection, dispatchable analysis, panic sweeps with ripgrep commands, weight benchmarking review, and origin privilege audits. - Severity-Prioritized Reporting: Classifies findings as Critical, High, or Medium with concrete mitigation code and a pre-launch checklist. - Use Case: Before launching a Polkadot parachain, run this Skill against your pallets/ directory to catch an ensure_signed guard on a privileged force_transfer call and an unchecked balance - amount subtraction before they reach production. ## Quick Start Ask the AI to scan the Substrate pallets in this repository for the 7 critical vulnerability patterns and report findings with severity and fixes.

Frequently Asked Questions about substrate-vulnerability-scanner

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I audit Substrate pallets for security vulnerabilities?

Audit Substrate pallets by checking each dispatchable for the 7 critical patterns: unchecked arithmetic, panics from unwrap or indexing, fixed weights on variable-cost operations, storage writes before validation, weak unsigned transaction validation, insecure randomness, and ensure_signed on privileged calls. This Skill walks through each pattern with detection commands and fixes.

How to prevent arithmetic overflow in Substrate runtime code?

Replace direct +, -, *, / operators with checked_* or saturating_* methods from sp_runtime traits. In release mode Rust primitives wrap silently, so balance and reward calculations must use checked_sub, checked_mul, or saturating_add and return DispatchError on overflow.

Why do panics in Substrate dispatchables cause DoS attacks?

A panic in a dispatchable stops the node from processing blocks, letting attackers halt the chain with crafted inputs. Avoid unwrap(), expect(), unchecked array indexing, and division by zero; validate all user input with ensure! and return DispatchError instead.

When should I use ensure_root instead of ensure_signed in FRAME?

Use ensure_root or custom origins like ForceOrigin for privileged operations such as emergency pause, fee updates, or force transfers. ensure_signed only proves some account signed, so any user could invoke admin functions if it guards privileged calls.

Does Substrate v0.9.25 fix storage writes before validation?

Yes, v0.9.25 introduced a transactional storage layer that rolls back writes when a dispatch fails. On earlier versions you must validate before writing or add the #[transactional] attribute manually to prevent state corruption on error.

What randomness source is safe for production Substrate chains?

Use BABE randomness via pallet_babe::RandomnessFromOneEpochAgo for production. pallet_randomness_collective_flip is vulnerable to validator collusion, and on-chain randomness should never be used to generate cryptographic keys.