# Auction created by ERC777 Tokens with tax can be stolen by re-entrancy attack

SizeSealed.createAuction lacks reentrancy guard; a taxed ERC777 base token lets an attacker reenter and register multiple auctions whose totalBaseAmount exceeds tokens actually received, draining the global pool.

- Payout: Contest reward
- Severity: medium
- Program: SIZE
- Credited: ronnyx2017
- Disclosed: 2023-01-09
- Write-up quality: 7/10
- Original: https://github.com/code-423n4/2022-11-size-findings/issues/192
- Library page: https://bugbountylibrary.com/r/c4%3A2022-11-size%3AM-04
- Tags: domain:web3 impact:funds-loss kind:contest platform:code4rena sev:medium tech:evm tech:solidity technique:chained technique:source-review vuln:accounting-error vuln:reentrancy

**Target:** SizeSealed.createAuction auction creation flow
**Root cause:** createAuction transfers the base token before finalizing auction accounting and has no reentrancy guard; an ERC777 sender hook can re-enter createAuction mid-transfer, and with a taxed token the contract receives less than the sum of recorded totalBaseAmount values.
**Steps:**
1. Deploy a taxed ERC777 base token (e.g. 50% burn on transfer) and register an ERC777TokensSender implementer for the seller in ERC1820Registry at `0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24`.
2. Seller calls `createAuction(baseToSell, ...)` with the taxed ERC777 as base token.
3. In `tokensToSend` hook (entry 0), re-enter `seller.createAuction(amount_cut_tax, ...)` to create a second auction.
4. On entry 1, call `ERC777(msg.sender).transferFrom(from, to, amount_cut_tax)` to move remaining tokens.
5. Observe auction 1 totalBaseAmount = 10e18 and auction 2 = 5e18 while contract balance is only 10e18, so sum of recorded base exceeds received tokens.
6. Later withdraw/claim from the inflated auctions to take more than deposited from the global pool, stealing from other auctions and treasury.
**How found:** Researcher noticed createAuction performs an external token transfer without a reentrancy guard and reasoned that ERC777 sender hooks (mandatory ERC1820 registration) plus a transfer-tax token would let the hook re-enter and desynchronize recorded totalBaseAmount from actual received balance; validated with a Foundry mainnet-fork PoC.
**Exploitation:** Attacker controls the base token (taxed ERC777) and registers an ERC1820 sender hook. During createAuction's token transfer, the hook re-enters createAuction to register additional auctions; because the tax reduces tokens actually received while totalBaseAmount is recorded at full requested amounts, the attacker's auctions collectively claim more base than was deposited, letting them withdraw excess from the shared contract pool.
**Escalation:** Multiple reentrant auctions amplify the discrepancy; the inflated totalBaseAmount lets the attacker drain the global pool covering other auctions and treasury.
**Insight:** When a contract records a user-supplied amount before/around an external token transfer, test ERC777 tokensToSend/tokensReceived hooks (and fee-on-transfer tokens) to see if recorded accounting can exceed actual balance; ERC777's mandatory ERC1820 registration makes the callback reachable for any attacker-deployed token.
