Threat Modeling
Structured process of identifying, evaluating, and prioritizing potential security threats to a system during the design phase before code is written.
Threat modeling is a proactive security practice where development teams systematically identify potential attack vectors, trust boundaries, and adversarial scenarios before writing code. In smart contract development, threat modeling is especially critical because deployed contracts are immutable and directly control financial assets—making post-deployment fixes extremely costly or impossible.
Why threat modeling matters in Web3
Traditional software can be patched after deployment. Smart contracts cannot. This asymmetry makes pre-deployment analysis essential:
- Immutability: Once deployed, vulnerabilities cannot be patched without complex migration strategies
- Transparent code: Attackers can read your source code and plan exploits
- High-value targets: Contracts often hold millions in TVL, creating strong adversarial incentives
- Composability risks: Your contract interacts with other protocols that may behave unexpectedly
The threat modeling process
1. Define the system
Document the protocol's architecture, trust assumptions, and asset flows:
- What assets does the contract hold or manage?
- Who are the privileged actors (admin, governance, keepers)?
- What external dependencies exist (oracles, other protocols)?
- What are the intended state transitions?
2. Identify threats
For each component and interaction, enumerate potential attack vectors:
- Can an attacker manipulate inputs to extract value?
- What happens if an external dependency fails or is compromised?
- Are there economic incentives for malicious behavior?
- Can privileged roles be abused?
3. Evaluate and prioritize
Score each threat by likelihood and impact:
| Severity | Description |
|---|---|
| Critical | Easy to exploit, total loss of funds |
| High | Difficult to exploit with high impact, or easy to exploit with yield loss |
| Medium | Limited impact or requires unusual conditions |
| Low | Minimal impact, informational |
4. Define mitigations
For each prioritized threat, specify concrete defensive measures:
- Code-level protections (access control, reentrancy guards)
- Architectural changes (separating custody from logic)
- Operational controls (timelocks, multisigs)
- Monitoring and alerting (circuit breakers)
STRIDE for smart contracts
The STRIDE framework, originally developed by Microsoft, adapts well to blockchain-specific threats:
- Spoofing:
tx.originvsmsg.senderconfusion - Tampering: Oracle manipulation via flash loans
- Repudiation: Missing event emissions for critical state changes
- Information Disclosure: Exposing private data on-chain
- Denial of Service: Unbounded loops, gas griefing
- Elevation of Privilege: Bypassing access controls
When to perform threat modeling
Threat modeling should occur at multiple stages:
- Design phase: Before any Solidity is written—define trust assumptions and invariants
- Pre-audit: Before engaging auditors—helps define audit scope and focus areas
- Post-upgrade: When protocol logic changes—reassess threats against new functionality
- Post-incident: After exploits in similar protocols—update threat models with new attack vectors
Common mistakes
- Skipping the design phase: Jumping straight to code and relying solely on post-implementation audits
- Ignoring economic threats: Focusing only on code-level bugs while missing tokenomics and incentive flaws
- Static threat models: Creating a threat model once and never updating it as the protocol evolves
- Overlooking composability: Not modeling how interactions with external protocols create emergent risks
Threat modeling is the foundation of a defense-in-depth security strategy. By identifying threats early, teams can architect solutions rather than patch symptoms.
Articles Using This Term
Learn more about Threat Modeling in these articles:
Related Terms
Defense in Depth
Layered security strategy combining multiple independent protections rather than relying on single security measures.
Audit Scope
The defined boundaries of a security audit, specifying which contracts, functions, and concerns will be reviewed.
STRIDE
Microsoft-developed threat classification framework covering Spoofing, Tampering, Repudiation, Information Disclosure, Denial of Service, and Elevation of Privilege.
Shift Left
Security practice of integrating testing, verification, and security analysis earlier in the software development lifecycle rather than deferring to post-implementation.
Need expert guidance on Threat Modeling?
Our team at Zealynx has deep expertise in blockchain security and DeFi protocols. Whether you need an audit or consultation, we're here to help.
Get a Quote

