DeFi Security & Audit Reading
Reading smart contract audits, common vulnerability patterns (reentrancy, oracle manipulation), rug pull detection, and tools for your own security analysis.
From Thrive on YouTube
Watch the matching Thrive video
Exchange Security for Traders: Protect Your Account From the Common Attacks
Part of Trading Psychology for Futures Traders. Education only. Not financial advice.
How to Read a Smart Contract Audit Report
A smart contract audit report is the closest thing DeFi has to a financial audit. It is a document produced by a security firm that examines a protocol's code for vulnerabilities, logic errors, and economic attack vectors. Learning to read these reports is a critical skill. It separates informed DeFi users from those blindly trusting "audited" labels.
| Executive summary | High-level overview of what was audited, the scope (which contracts), methodology used, and total findings by severity. Read this first: it tells you how thorough the audit was and whether critical issues were found. |
| Scope & methodology | Lists exact contract addresses, commit hashes, and lines of code reviewed. A narrow scope (only 2 of 10 contracts audited) is a red flag. Methodology should include manual review, automated tools, and economic attack modeling. |
| Findings (Critical/High) | Issues that can directly result in loss of user funds, unauthorized access, or protocol insolvency. Any unresolved Critical or High finding is a dealbreaker. Do not deposit funds in the protocol. |
| Findings (Medium/Low) | Medium issues may lead to unexpected behavior or limited fund loss under specific conditions. Low issues are best practices violations or gas optimizations. These matter less for safety but indicate code quality. |
| Informational/Gas | Style suggestions, documentation gaps, and gas efficiency improvements. Not security-relevant but reveal the team's engineering maturity. Many informational findings suggest the codebase was rushed. |
| Remediation status | Shows whether the team fixed each finding. Look for "Resolved" on all Critical/High findings. "Acknowledged" means the team saw the issue but chose not to fix it. Read their justification carefully. |
Major Audit Firms and Their Reputations
Not all audits are created equal. The firm's track record, methodology, and depth of review vary dramatically. A $10,000 automated-only audit from an unknown firm provides almost no security assurance compared to a $500,000+ manual audit from a top-tier firm.
Gold standard. Known for deep manual reviews and custom tooling (Slither, Echidna, Medusa). Their audits frequently find issues that automated tools miss. Clients include Ethereum Foundation, Compound, MakerDAO. If a protocol has a Trail of Bits audit, it is a strong positive signal.
The team behind the most widely used Solidity libraries. Their auditors understand both the standard patterns and novel attack vectors. Strong track record with Aave, Compound, Uniswap. Their open-source libraries (OpenZeppelin Contracts) are de facto standards.
Specializes in formal verification: mathematically proving that contract code satisfies specified properties. Goes beyond finding bugs to proving their absence. Used by Aave v3, Compound, and institutional DeFi protocols. Most rigorous methodology available.
Decentralized audit network of elite independent security researchers. Review quality depends on the specific researchers assigned, but the talent pool includes some of the best minds in blockchain security. Used by Uniswap, Aave, and leading protocols.
Competitive audit platforms where many auditors review the same codebase simultaneously. Broader coverage (many eyes) but variable quality. Useful as a complement to a primary audit, not as a replacement. Bug bounty-style incentive model.
Red Flags in Unaudited and Poorly Audited Protocols
An audit is necessary but not sufficient. Many exploited protocols had audits: the audit either missed the vulnerability, or the team deployed different code than what was audited. Look for these red flags beyond the audit itself.
The audit covers v1 contracts, but the protocol deployed v2 with significant changes. Always verify the audited commit hash matches the deployed bytecode. Etherscan's contract verification page shows whether source code matches deployment.
Many DeFi protocols launch without any audit, especially on faster chains like Solana and newer L2s where deployment is cheap. "Audit in progress" with no timeline is functionally equivalent to no audit. Do not deposit meaningful capital.
If the audit found critical issues and the team marked them as "Acknowledged" without fixing, the protocol is knowingly operating with exploitable vulnerabilities. This is indefensible.
Unknown firms charging $5,000-10,000 for an "audit" are often running automated scans with minimal manual review. One audit from an unknown firm is almost worthless from a security perspective.
If the contract source code is not verified on Etherscan/Sourcify, you cannot independently verify what the code does. Legitimate protocols always verify their source code publicly.
Common Vulnerability Patterns
Most DeFi exploits fall into a handful of recurring categories. Understanding these patterns helps you assess protocol risk even without reading the code yourself.
| Reentrancy | An attacker calls back into a contract before the first execution completes, draining funds through repeated withdrawals. The DAO hack ($60M, 2016) was reentrancy. Modern defense: checks-effects-interactions pattern and reentrancy guards. Still found in new contracts: the Curve pool exploit (2023, $60M+) was a reentrancy bug in Vyper's compiler. |
| Oracle manipulation | An attacker manipulates the price feed a protocol relies on, then exploits the mispriced state. Flash loan the asset, inflate the oracle price by trading on a low-liquidity DEX the oracle reads, borrow against the inflated collateral, and repay the flash loan. Mango Markets ($114M, 2022) was oracle manipulation. |
| Flash loan attacks | Flash loans provide uncollateralized capital within a single transaction. An attacker borrows millions, manipulates a market or protocol state, extracts profit, and repays the loan: all atomically. The attack is risk-free for the attacker because the transaction reverts if any step fails. |
| Access control failures | Admin functions callable by anyone, missing role checks, or accidentally public initialization functions. The Ronin Bridge hack ($625M) exploited compromised admin keys. The Wormhole hack ($320M) exploited a missing signature verification. |
| Logic errors | Incorrect math, off-by-one errors, rounding issues, or flawed state machine transitions. These are the hardest to catch because the code compiles and runs. It just does the wrong thing. Compound accidentally distributed $80M in extra COMP tokens due to a logic error in their distribution function. |
Rug Pull Detection Checklist
A rug pull is a deliberate exit scam where the team drains value from the protocol. Unlike exploits (where external attackers find vulnerabilities), rug pulls are insider jobs. The following checklist helps identify protocols at high rug risk.
If the contract owner can mint tokens, change fees, pause transfers, or withdraw liquidity, the team retains the ability to rug. Check if ownership is renounced (owner = 0x0) or transferred to a timelock/multisig. Use Etherscan's "Read Contract" tab to check the owner() function.
LP tokens should be locked in a time-lock contract (Team.finance, Unicrypt) for a meaningful period (6+ months minimum). If the team holds unlocked LP tokens, they can remove all liquidity at any time, leaving token holders with an untradeable asset.
Upgradeable proxy contracts allow the team to change the entire contract logic at any time. This is powerful for legitimate upgrades but lethal for rug pulls: the team can deploy new logic that drains all funds. A timelock (24-48 hour delay) on upgrades gives users time to exit.
Some tokens contain hidden functions that allow the owner to mint unlimited tokens. These may be obfuscated in the code (named something innocuous) or hidden behind proxy patterns. Token Sniffer and similar tools scan for these automatically.
Functions that allow the owner to prevent specific addresses from selling are a classic rug mechanism. The team buys, then enables the blacklist so only they can sell. Check the transfer() function for conditional logic based on sender/receiver addresses.
Anonymity alone is not a red flag (many legitimate crypto builders are pseudonymous). But an anonymous team with no on-chain history, no prior projects, and no reputation to lose has minimal accountability. Weight this alongside other factors.
Tools for Your Own Analysis
You do not need to be a Solidity developer to perform meaningful security due diligence. These tools give any DeFi user the ability to verify protocols before depositing funds.
| Etherscan (etherscan.io) | Read verified contract source code, check ownership functions, verify proxy implementations, view transaction history, and confirm token holder distribution. The "Contract" tab is your primary research tool. Check "Read Contract" for owner(), paused(), and admin roles. |
| DeFi aggregators | Track TVL trends, protocol revenue, chain-by-chain breakdown, and audit status. Sudden TVL drops can indicate smart money exiting. Many maintain comprehensive databases of DeFi exploits with amounts and root causes. |
| Revoke.cash | Review and revoke token approvals you have granted to smart contracts. Old approvals on abandoned or compromised protocols are a latent risk: if the contract is exploited, the attacker can drain any tokens you approved. Periodically review and revoke unnecessary approvals. |
| Token Sniffer (tokensniffer.com) | Automated analysis of token contracts for rug pull indicators: hidden mints, transfer restrictions, fee manipulation, and similar patterns. Assigns a risk score. Not foolproof but catches common scam patterns. |
| Tenderly (tenderly.co) | Simulate transactions before execution. See exactly what will happen when you interact with a contract, which tokens move, which approvals are set, and whether the transaction succeeds. Essential for complex DeFi interactions. |
| De.Fi REKT database | Comprehensive database of DeFi hacks, exploits, and rug pulls with postmortem analysis. Study past exploits to recognize patterns. If a new protocol uses the same architecture as a previously exploited one, the risk is elevated. |
An audit is not insurance
Oracle Risk: The Hidden Attack Surface
Oracles are the bridge between on-chain contracts and off-chain reality. Every lending protocol, derivatives platform, and algorithmic stablecoin depends on oracles for price data. If the oracle reports a wrong price (whether from manipulation, latency, or failure), the protocol acts on incorrect information. Protocols using a single oracle source, or using on-chain TWAP (Time-Weighted Average Price) from low-liquidity pools, are especially vulnerable to manipulation.
Flash Loan Attack Vectors
Flash loans amplify every other vulnerability. They give an attacker unlimited capital for the duration of a single transaction. A protocol that is secure against a $100K attack may be completely broken when an attacker can deploy $100M in a single block. When evaluating protocol security, always ask: "What would happen if someone could temporarily access $500M and interact with this protocol?" If the answer is "they could drain it," the protocol has a flash loan vulnerability, whether or not anyone has exploited it yet.
The 5-minute security due diligence
1.A protocol's audit report shows 2 Critical findings marked 'Acknowledged' but not 'Resolved.' What should you do?
2.What makes oracle manipulation one of the most common DeFi exploit vectors?
3.A new DeFi protocol uses an upgradeable proxy contract with no timelock. Why is this a rug pull risk?
4.You find a token where the owner() function returns an externally owned account (not a multisig or 0x0). What does this indicate?
5.Why should you periodically use Revoke.cash to review your token approvals?
Put this lesson to work
Free on Thrive, no account needed.