Analyzing a Major Web3 Vulnerability and Its Resolution
A DeFi protocol's withdraw function sent Ether before updating the user's balance, allowing a reentrancy attack. An attacker could repeatedly call withdraw via a fallback function to drain the contract's funds.
Published on securrtech.medium.com
The landscape of Web3, with its decentralized ethos, has brought revolutionary changes to the internet, enabling trustless interactions and tokenized ecosystems. However, the complex interplay of cryptography, smart contracts, and decentralized applications (dApps) has also introduced novel vulnerabilities.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Impact
The attacker could drain the contract's balance, potentially stealing all funds held by the protocol.
What the attacker needed
Victim contract holds funds; attacker can deploy a contract
How it was found
- The attacker calls withdraw with a chosen amount.
- The contract sends Ether to the attacker's contract, triggering its fallback function.
- The fallback function calls withdraw again before the first call updates the balance.
- The attacker repeats this to drain the contract's funds.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
A smart contract is a program on a blockchain that holds and moves money automatically. This one paid out funds before recording that it had done so, so an attacker could trick it into paying again and again until it was empty. This is called a reentrancy attack.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.