# TokenManager's flow limit logic is broken for ERC777 tokens

TokenManager measures flow via balance delta; an ERC777 receiver hook inflates its own balance, over-counting flow-in and DoS-ing the bridge flow limit.

- Payout: Contest reward
- Severity: medium
- Program: Axelar Network
- Credited: bart1e
- Disclosed: 2023-11-29
- Write-up quality: 7/10
- Original: https://github.com/code-423n4/2023-07-axelar-findings/issues/332
- Library page: https://bugbountylibrary.com/r/c4%3A2023-07-axelar%3AM-02
- Tags: domain:web3 impact:dos kind:contest platform:code4rena sev:medium tech:evm tech:solidity technique:source-review vuln:accounting-error vuln:dos

**Target:** TokenManagerLockUnlock / TokenManagerLiquidityPool _giveToken flow accounting
**Root cause:** _giveToken returns balanceOf(to) delta after transfer; an ERC777 tokensReceived hook can send extra tokens to the receiver mid-transfer, inflating the returned amount beyond the actual bridged amount.
**Steps:**
1. Deploy TokenManager (Lock/Unlock or LiquidityPool) over an ERC777 token T.
2. Attacker contract calls sendToken with dust amount; TokenManager calls _giveToken -> safeTransfer to attacker contract.
3. In `tokensReceived` hook, attacker's helper contract transfers a large amount of T to the attacker contract.
4. _giveToken returns balanceOf(to)-balance which is now huge; giveToken calls _addFlowIn(huge).
5. Flow-in reaches flowLimit, so subsequent legitimate transfers revert in _addFlow (FlowLimitExceeded).
6. Repeat (send tokens back to helper) to keep flow saturated; recover only by setting flowLimit=0.
**How found:** Code review of _giveToken's balance-delta accounting combined with knowledge that ERC777 transfer triggers a receiver hook that can mutate the receiver's balance before the delta is computed.
**Exploitation:** Attacker needs only dust bridged amount plus a large T balance held in a helper contract; the ERC777 hook self-transfers to inflate the measured flow-in, saturating the flow limit and blocking other users' inbound transfers (DoS).
**Insight:** Any accounting that derives transferred amount from balanceOf deltas is manipulable when the token has transfer hooks (ERC777/ERC677) or rebasing behavior; check whether the receiver can change its own balance mid-transfer.
