Jaypeggerz Hack
What happened
On December 29, 2022, an attacker exploited Jaypeggers (JAY), an NFT tax-loss-harvesting app on Ethereum, for about 15.32 ETH. Estimates of the value range from about $17.9K (CertiK) to about $18.5K (SolidityScan); the existing record listed $18,384. The attacker used a flash loan and re-entered the JAY contract through a fake ERC-721 token. This let them sell JAY at an inflated price. The profit went to Tornado Cash and Aztec Network. Hypernative says it detected the attack and notified the Jaypeggers team in real time.
In JAY, the token price is the contract's ETH balance divided by the total JAY supply. buyJay() accepted any contract as an ERC-721 collection and called that contract's transferFrom while the purchase was still in progress. When that call happened, the buyer's ETH was already in the contract, but the matching JAY had not yet been minted. sell() had no reentrancy guard, so a sale made from inside the callback was priced against an inflated ETH balance.
- Attacker:
0x0348d20b74ddc0ac9bfc3626e06d30bb6fac213b - Exploit contract:
0xed42cb11b9d03c807ed1ba9c2ed1d3ba5bf37340 JAYcontract:0xf2919D1D80Aff2940274014bef534f7791906FF2- Exploit transaction:
0xd4fafa1261f6e4f9c8543228a67caf9d02811e4ad3058a2714323964a8db61f6
How it happened
- The attacker funded a wallet through Tornado Cash, deployed an exploit contract and took a flash loan of 72.5 WETH. The existing record names Balancer as the lender.
- The attacker spent 22 ETH buying
JAYnormally. - The attacker called
buyJay()with another 50.5 ETH, passing its own malicious contract as the ERC-721 token to deposit. - When
JAYcalledtransferFromon the fake NFT contract, that contract re-enteredJAYand calledsell()for all itsJAY. The 50.5 ETH already sat in the contract's balance, but no matchingJAYhad been minted, so the sale was priced too high. - The attacker ran this loop twice in the same transaction, then repaid the flash loan. About 15.32 ETH of profit remained, which was sent to Tornado Cash and Aztec.
Protocol details
Evidence
- report @CertiKAlert incident report twitter.com
- report CertiK Alert: flash loan attack on @jaypeggerz ($JAY) twitter.com
- transaction etherscan.io transaction 0xd4fa…61f6 etherscan.io
- address etherscan.io address 0x0348…213b etherscan.io
- address etherscan.io address 0xed42…7340 etherscan.io
- analysis DeFiLlama defillama.com
- analysis JAY Token Exploit — Reentrancy Attack (SolidityScan) blog.solidityscan.com
- analysis Jaypeggers Exploit (Hypernative) hypernative.io
Understand the attack patterns
Build your security review skills
Work through hands-on labs covering real exploit mechanics, review techniques, and defensive patterns.