โ ๏ธ Common Vulnerabilities: Reentrancy & More
Understand the top 10 smart contract attack vectors
Protect your dApp from common vulnerabilities
Your Progress
0 / 5 completed๐ Vulnerability Catalog
Beyond the big four (reentrancy, overflow, access control, front-running), production contracts face dozens of subtle vulnerabilities. Logic errors from incorrect assumptions. External call risks where malicious contracts manipulate your state. Gas-related attacks that lock contracts by hitting block limits. DoS vectors where griefers break core functionality. This section catalogs 14 common vulnerabilities with code examples, exploitation techniques, and fixes. Recognizing these patterns is the first step to writing secure contracts.
๐ฎ Interactive: Vulnerability Database
Browse vulnerabilities by category. Each includes vulnerable code, exploitation method, and secure fix.
Logic Errors
Business logic flaws and incorrect assumptions
Timestamp Dependence
MediumUsing block.timestamp for critical logicโminers can manipulate ยฑ15 seconds
// โ Vulnerable
function claim() public {
require(block.timestamp > deadline);
// Miner can manipulate within 15s window
}Use block.number instead, or accept timestamp manipulation risk for non-critical logic.
Unchecked Return Values
HighIgnoring return values from external callsโsilent failures
// โ Vulnerable
token.transfer(recipient, amount);
// If transfer fails, execution continuesrequire(token.transfer(...), "Transfer failed") or use SafeERC20 library.
Race Conditions
MediumMultiple transactions can manipulate state in unexpected order
// โ Vulnerable
function approve(uint amount) { allowance = amount; }
function transferFrom() { /* uses allowance */ }
// Attacker frontuns approve() to drain old + new allowanceUse increaseAllowance/decreaseAllowance pattern instead of approve().
Default Visibility
CriticalFunctions without visibilityโpublic by default in old Solidity
// โ Vulnerable (Solidity <0.5)
function withdraw() { /* no visibility = public! */ }Always explicitly declare function visibility: public, external, internal, private.
๐ฎ Interactive: Attack Simulation
Step through a reentrancy attack in real-time. See how the exploit unfolds step-by-step.
Attacker deploys malicious contract
Contract deployed with fallback function
๐ฏ Prevention Checklist
1. Validate inputs 2. Update state 3. External calls last
OpenZeppelin modifier prevents nested calls
Let users withdraw funds, don't push to them
Always declare public/external/internal/private
Never ignore call(), transfer(), delegatecall() results
Limit array sizes or use pull pattern