Polygon Hack
What happened
In early December 2021, an attacker, or a group of attackers, stole 801,601 MATIC from Polygon's PoS genesis MRC20 contract, the system contract that holds the chain's native MATIC. They used a bug that could have drained all of the roughly 9.28 billion MATIC the contract held. Whitehat Leon Spacewalker reported the flaw through Immunefi on December 3. While Polygon prepared a fix, a second whitehat reported the same bug on December 4, and the blackhat theft took place that day according to CoinDesk. Validators applied an emergency hard fork on December 5 at block 22,156,660, which removed the vulnerable function.
Reported USD values for the stolen MATIC range from about $1.4 million (CoinDesk) to over $2 million (The Block), depending on the price used. Polygon said it would bear the loss. It paid Leon Spacewalker $2.2 million in stablecoins and the second reporter 500,000 MATIC, about $3.46 million in bounties combined, and disclosed the incident publicly on December 29, 2021, citing the practice of silent patching for critical bugs.
How it happened
- The MRC20 contract offered
transferWithSig()for gasless transfers. It recovers the token owner from a packed signature usingecrecovery, a wrapper aroundecrecover, and passes that address asfromto_transferFrom(). ecrecoveryreturns the zero address when the packed signature is not exactly 65 bytes, andtransferWithSig()never rejected a zero-address signer, so no valid signature was needed.- Neither
_transferFrom()nor_transfer()checked thatfromhad enough balance or allowance._transfer()only checked that the recipient was not the MRC20 contract itself. - By sending a malformed signature with the attacker as
toand an arbitraryamount, a caller could move MATIC out of the contract's balance. A blackhat used this to take 801,601 MATIC before the December 5 fork removedtransferWithSig.
Protocol details
Evidence
Understand the attack patterns
Build your security review skills
Work through hands-on labs covering real exploit mechanics, review techniques, and defensive patterns.