Skip to content
Race condition Audit finding Intermediate

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.

shenwilly Follow

Originally disclosed on Code4rena

Submitted by shenwilly, also found by wuwe1

LiquidityPool.sol#L523

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, tokensToSend ERC777 hook is called and Alice reenters depositFor.
  • As the previous deposit hasn’t been taken into account, the reentrancy passes the depositCap check.
  • 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


The original report as published on Code4rena, by shenwilly. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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

  1. Start with an empty ERC777 liquidity pool capped at 1,000 tokens.
  2. Alice deposits 1,000 tokens.
  3. During the ERC777 tokensToSend hook, Alice reenters depositFor.
  4. The reentrant deposit passes the depositCap check because the first deposit is not yet recorded.
  5. 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.

More by shenwilly

View all

12 more disclosed reports, best first.

More from Backd Tokenomics contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Race conditions

The lesson behind this report.

Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.