substrate-vulnerability-scanner
यह क्या करती है
Substrate के रनटाइम मॉड्यूल्स, जिन्हें pallets कहते हैं, में ज्ञात कमज़ोरियाँ जाँचती है, जो नोड को क्रैश कर सकती हैं या अनधिकृत काम होने दे सकती हैं। यह Polkadot या दूसरी Substrate चेन बनाने वाले डेवलपर्स और ऑडिटर्स के लिए है।
कब इस्तेमाल करें
- ✓जब कोई ऑडिटर कस्टम Substrate pallet या FRAME रनटाइम की समीक्षा करता है।
- ✓जब कोई डेवलपर Polkadot या Substrate चेन के weights और origin checks जाँचता है।
- ✓जब कोई टीम लॉन्च के लिए Substrate चेन तैयार करके सुरक्षा स्कैन चाहती है।
Skill का लिंक
https://github.com/trailofbits/skills/blob/main/plugins/building-secure-contracts/skills/substrate-vulnerability-scanner/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“लॉन्च से पहले मेरे कस्टम Substrate pallet में ओवरफ़्लो की समस्याएँ और गलत origin checks जाँचिए।”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
यह स्किल Substrate और FRAME के लिए सात खास पैटर्न खोजती है, जैसे अंकगणित ओवरफ़्लो, weights और unsigned transaction की जाँच। यह जो मिलता है उसकी रिपोर्ट देती है और हर मामले का जोखिम समझाती है।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।
Substrate Vulnerability Scanner
1. Purpose
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.
2. When to Use This Skill
- Auditing custom Substrate pallets
- Reviewing FRAME runtime code
- Pre-launch security assessment of Substrate chains (Polkadot parachains, standalone chains)
- Validating dispatchable extrinsic functions
- Reviewing weight calculation functions
- Assessing unsigned transaction validation logic
3. Platform Detection
File Extensions & Indicators
- Rust files:
.rs
Language/Framework Markers
// 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]
Project Structure
pallets/*/lib.rs- Pallet implementationsruntime/lib.rs- Runtime configurationbenchmarking.rs- Weight benchmarksCargo.tomlwithframe-*dependencies
Tool Support
- cargo-fuzz: Fuzz testing for Rust
- test-fuzz: Property-based testing framework
- benchmarking framework: Built-in weight calculation
- try-runtime: Runtime migration testing
4. How This Skill Works
When invoked, I will:
- Search your codebase for Substrate pallets
- Analyze each pallet for the 7 vulnerability patterns
- Report findings with file references and severity, above them a coverage table carrying a verdict for every pattern
- Provide fixes for each identified issue
- Check weight calculations and origin validation
5. Vulnerability Patterns (7 Critical Patterns)
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.
Pattern Summary:
Arithmetic Overflow ⚠️ CRITICAL
- Direct
+,-,*,/operators wrap in release mode - Must use
checked_*orsaturating_*methods - Affects balance/token calculations, reward/fee math
- Direct
Don't Panic ⚠️ CRITICAL - DoS
- Panics cause node to stop processing blocks
- No
unwrap(),expect(), array indexing without bounds check - All user input must be validated with
ensure!
Weights and Fees ⚠️ CRITICAL - DoS
- Incorrect weights allow spam attacks
- Fixed weights for variable-cost operations enable DoS
- Must use benchmarking framework, bound all input parameters
Verify First, Write Last ⚠️ HIGH (Pre-v0.9.25)
- Storage writes before validation persist on error (pre-v0.9.25)
- Pattern: validate → write → emit event
- Upgrade to v0.9.25+ or use manual
#[transactional]
Unsigned Transaction Validation ⚠️ HIGH
- Insufficient validation allows spam/replay attacks
- Prefer signed transactions
- If unsigned: validate parameters, replay protection, authenticate source
Bad Randomness ⚠️ MEDIUM
pallet_randomness_collective_flipvulnerable to collusion- Must use BABE randomness (
pallet_babe::RandomnessFromOneEpochAgo) - Use
random(subject)notrandom_seed()
Bad Origin ⚠️ CRITICAL
ensure_signedallows any user for privileged operations- Must use
ensure_rootor custom origins (ForceOrigin, AdminOrigin) - Origin types must be properly configured in runtime
For complete vulnerability patterns with code examples, see VULNERABILITY_PATTERNS.md.
6. Scanning Workflow
Step 1: Platform Identification
- Verify Substrate/FRAME framework usage
- Check Substrate version (v0.9.25+ has transactional storage)
- Locate pallet implementations (
pallets/*/lib.rs) - Identify runtime configuration (
runtime/lib.rs)
Step 2: Dispatchable Analysis
For each #[pallet::call] function:
- Arithmetic: Uses checked/saturating op
अक्सर पूछे जाने वाले सवाल
पैनिक-आधारित डिनायल ऑफ़ सर्विस क्या है?
यह ऐसा जोखिम है जिसमें गलत इनपुट आने पर कोड नोड को क्रैश कर देता है, और स्किल इसे खोजती है।
क्या यह unsigned transactions को कवर करती है?
हाँ। यह unsigned transaction वैलिडेशन लॉजिक की जाँच करती है।
यह किसके लिए है?
उन डेवलपर्स और ऑडिटर्स के लिए जो कस्टम pallets, FRAME रनटाइम कोड या Substrate चेन पर काम करते हैं।
जानकारी
लेखक का मूल विवरण
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.
repo: trailofbits/skills
लोकप्रियता
- GitHub स्टार
- 8.0k
- रैंकिंग में स्थान
- #12664
- लाइसेंस
- CC-BY-SA-4.0
- अपडेट की गई
- 2/11/2026
कमेंट
- …
इस repository की और skills
audit-context-building
8.0kयह आपके एजेंट को सुरक्षा जाँच से पहले किसी अनजान कोड को समझने में मदद करती है, हर फ़ंक्शन की मान्यताएँ और निर्भरताएँ नक्शे में दिखाकर।
algorand-vulnerability-scanner
8.0kयह आपके एजेंट को Algorand कॉन्ट्रैक्ट्स में 11 आम सुरक्षा समस्याएँ जाँचने में मदद करती है, जैसे रीकीइंग हमले और बिना जाँची फ़ीस।
audit-prep-assistant
8.0kयह आपके एजेंट को बाहरी सुरक्षा समीक्षा के लिए कोड तैयार करने में मदद करती है, जैसे स्टैटिक एनालिसिस, टेस्ट कवरेज और दस्तावेज़ीकरण।
cairo-vulnerability-scanner
8.0kयह आपके एजेंट को StarkNet के Cairo कॉन्ट्रैक्ट्स में 6 गंभीर समस्याएँ जाँचने में मदद करती है, जैसे ओवरफ़्लो और सिग्नेचर रीप्ले।
मिलती-जुलती skills
reverse-engineer-anything
422kयह आपके एजेंट को REA टूल से शिप हुई ऐप्स और पैकेज को अंदर से समझने, वर्ज़न की तुलना करने या दोबारा बनाने में मदद करती है।
1password
394kयह आपके एजेंट को 1Password CLI सेट करने, साइन इन करने और सीक्रेट्स की वैल्यू चैट में छापे बिना उन्हें पढ़ने या इस्तेमाल करने में मदद करती है।
healthcheck
394kयह आपके एजेंट को उस कंप्यूटर या सर्वर का सुरक्षा ऑडिट करने देती है जिस पर OpenClaw चलता है, जिसमें SSH, firewall, अपडेट और बैकअप शामिल हैं, और फिर सुरक्षित सुधार सुझाती है।