Jaypeggerz Hack

Reported loss $18K
Ethereum
Flash Loan Attack

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
  • JAY contract: 0xf2919D1D80Aff2940274014bef534f7791906FF2
  • Exploit transaction: 0xd4fafa1261f6e4f9c8543228a67caf9d02811e4ad3058a2714323964a8db61f6

How it happened

  1. 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.
  2. The attacker spent 22 ETH buying JAY normally.
  3. The attacker called buyJay() with another 50.5 ETH, passing its own malicious contract as the ERC-721 token to deposit.
  4. When JAY called transferFrom on the fake NFT contract, that contract re-entered JAY and called sell() for all its JAY. The 50.5 ETH already sat in the contract's balance, but no matching JAY had been minted, so the sale was priced too high.
  5. 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

Classification Token / Reentrancy
Protocol Type Exploit/Flash Loan Attack
Affected asset / contract JAY
Implementation language Solidity
Protocol links Website @jaypeggerz

Build your security review skills

Work through hands-on labs covering real exploit mechanics, review techniques, and defensive patterns.