Over $10 billion in cryptocurrency has been stolen through hacking. Here's how it happens.
// Reentrancy Attack (The DAO Hack - $60M stolen)
// Vulnerable contract:
function withdraw(uint amount) {
require(balances[msg.sender] >= amount);
msg.sender.call{value: amount}(""); // Attacker reenters here!
balances[msg.sender] -= amount; // Too late!
}Found an issue with this guide? Send a correction with the article URL and your example. About our learning material.
Subscribe to Code Hacker and get hands-on access to 40+ premium courses — Ethical Hacking, Kali Linux, Metasploit, Network Hacking, Bug Bounty & more!