Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Static Analysis

Odin Scan includes deterministic static analysis rules that complement the AI-based detection. These rules provide precise, reproducible checks for known vulnerability patterns with zero ambiguity.

How Static Analysis Complements AI

AI-based analysis excels at detecting complex, context-dependent vulnerabilities that require understanding intent and business logic. Static analysis excels at catching well-defined patterns with zero false positives in common cases.

AspectAI AnalysisStatic Analysis
Pattern detectionComplex, contextualWell-defined, deterministic
False positive rateHigher (reduced by verification)Very low
Novel vulnerabilitiesCan detect previously unseen patternsLimited to known patterns
ReproducibilityMay vary between runsIdentical results every run

By running both in parallel, Odin Scan achieves broad coverage (AI) with high precision (static analysis).

CosmWasm Rules

The following rules are currently available for CosmWasm contracts:

RuleSeverityDescription
missing_access_controlCriticalDetects execute handlers and privileged operations that lack authorization checks. Looks for functions that modify state or transfer funds without verifying the caller’s identity or role.
unsafe_mathHighIdentifies arithmetic operations that could overflow or underflow. Flags direct use of +, -, *, / operators on integer types instead of checked or saturating alternatives.
unchecked_addrHighFinds usage of Addr::unchecked() where user-supplied strings are converted to addresses without validation via deps.api.addr_validate().
input_validationMediumDetects missing validation on message fields and function parameters. Checks for unbounded strings, missing range checks on numeric inputs, and unvalidated enum variants.
storage_key_collisionsMediumIdentifies storage items that use identical or overlapping keys, which can cause silent data corruption when two state items write to the same storage slot.
predictable_randomnessMediumDetects use of predictable sources for randomness such as block height, block time, or transaction hashes. These values can be manipulated or predicted by validators.
unsaved_storageLowFinds state modifications that are computed but never persisted to storage. Catches cases where a value is loaded, modified in memory, but the save() call is missing.
unbounded_loopsLowIdentifies loops that iterate over collections without pagination or upper bounds. In a smart contract context, unbounded iteration can exceed gas limits and cause transaction failures.

Rule Details

Each rule provides:

  • Exact code location – file path and line number of the flagged pattern
  • Explanation – why the pattern is problematic
  • Remediation – suggested code change to resolve the issue
  • Code examples – demonstrating both the vulnerable and secure pattern

Platform Coverage

Static analysis rules are organized by platform. Each platform has its own set of rules tailored to its specific vulnerability landscape:

PlatformStatusRule CountNotes
CosmWasmActive8+ rulesFull coverage of common CosmWasm vulnerabilities
SolanaPlannedWill cover Anchor constraints, account validation, PDA safety
EVMActiveIncludes additional Solidity-specific checks

Integration With AI Analysis

Static analysis runs in parallel with AI analysis. When a static analysis rule and an AI model both flag the same code location for the same category, the aggregated finding receives a confidence boost. This cross-validation between deterministic and probabilistic detection methods produces high-confidence results.