ERC777 tokens can bypass depositCap guard
The deposit function in a liquidity pool did not guard against reentrancy when the underlying token was an ERC777 token. An attacker could reenter the deposit function during the token transfer hook and bypass the deposit cap, allowing more tokens to be deposited than the governance-set limit.
Submitted by shenwilly, also found by wuwe1
When ERC777 token is used as the underlying token for a LiquidityPool, a depositor can reenter depositFor and bypass the depositCap requirement check, resulting in higher total deposit than intended by governance.
Proof of Concept
- An empty ERC777 liquidity pool is capped at 1.000 token.
- Alice deposits 1.000 token. Before the token is actually sent to the contract,
tokensToSendERC777 hook is called and Alice reentersdepositFor. - As the previous deposit hasn’t been taken into account, the reentrancy passes the
depositCapcheck. - Pool has 2.000 token now, despite the 1.000 deposit cap.
Recommended Mitigation Steps
Add reentrancy guards to depositFor.
chase-manning (Backd) confirmed and resolved
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the deposit function updates state and checks the cap before the token transfer completes, and the ERC777 token's transfer hook allows the caller to reenter before the first deposit is recorded.
Impact
The pool could hold more tokens than the governance-set deposit cap, breaking the intended limit.
What the attacker needed
ERC777 token used as underlying; attacker can deposit tokens
The fix
Reentrancy guards should be added to the deposit function; the report states the issue was confirmed and resolved.
How it was found
- Start with an empty ERC777 liquidity pool capped at 1,000 tokens.
- Alice deposits 1,000 tokens.
- During the ERC777 tokensToSend hook, Alice reenters depositFor.
- The reentrant deposit passes the depositCap check because the first deposit is not yet recorded.
- The pool now holds 2,000 tokens despite the 1,000 cap.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A deposit cap is a limit on how many tokens can be put into a pool. The pool checked the limit before the tokens actually arrived, so an attacker could call the deposit function again during that brief moment and sneak in extra tokens. This is called a reentrancy attack: the contract is re-entered before it finishes its first job.
What is Race condition?
Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.