π‘οΈAdvancedβ± 120 min
Smart Contract Security on Base
Security is the most critical skill for any Solidity developer. This quest covers the top vulnerability classes: reentrancy, integer overflow, access control, oracle manipulation, flash loan attacks, and more. Each challenge has a vulnerable contract you must exploit, then patch.
securitysolidityreentrancyauditethernaut
Prerequisites:Token Launch & Flywheel Mastery
π
Ability to audit Solidity contracts and prevent common attack vectors
Step 1: Reentrancy β exploit and fix
The classic reentrancy attack drains a contract by re-entering before balances are updated. Exploit the vulnerable contract, then apply the checks-effects-interactions pattern to fix it.
Step 1 β solidity
// Vulnerable contract
contract VulnerableBank {
mapping(address => uint) public balances;
function withdraw() external {
uint amount = balances[msg.sender];
(bool success,) = msg.sender.call{value: amount}('');
require(success);
balances[msg.sender] = 0; // β Updated AFTER external call
}
}
// Fixed contract
contract SafeBank {
mapping(address => uint) public balances;
function withdraw() external {
uint amount = balances[msg.sender];
balances[msg.sender] = 0; // β
Update BEFORE external call
(bool success,) = msg.sender.call{value: amount}('');
require(success);
}
}β
Checkpoint
Reentrancy attack proof-of-concept deployed and exploit transaction confirmed
1 / 3
