Skip to content
Business logic Audit finding Intermediate

Availability of deposit invariant can be bypassed

The deposit invariant that deposits are active only up to the lpETH and lpETHVault contracts being set can be bypassed. An attacker can donate ETH directly to the contract and then claim lpETH via a previously locked position or by sandwiching the convertAllETH call, gaining lpETH without locking tokens before the contracts are set.

0xnev Follow with Krace, gumgumzum and 29 others

Originally disclosed on Code4rena

Submitted by 0xnev, also found by Krace, 0xrex (1, 2), gumgumzum, novamanbg, Greed, y4y, DMoore, 0x04bytes, 0xBugSlayer, sldtyenj12, yovchev_yoan, 0xJoyBoy03 (1, 2), sandy, Evo, Kirkeelee, Sajjad, d3e4, samuraii77, Pechenite, TheFabled, Rhaydden (1, 2), web3er, ZanyBonzy, SBSecurity, nfmelendez, Topmark, XDZIBECX, Bigsam, shaflow2, 0xSecuri, petarP1998, bbl4de, _karanel, and btk

Impact

One of the main invariants stated in the audit is the following:

Deposits are active up to the lpETH contract and lpETHVault contract are set

However, there are currently two ways this invariant can be broken, allowing users to gain lpETH without explicitly locking tokens before contracts are set.

  1. Sandwich a call to convertAllETH by front-running to directly donate ETH and then back-running to claim lpETH via multiple lock positions
  2. Bundle a transaction of donation and claiming with a previously locked position of wrapped LRT

This bypasses the onlyBeforeDate(loopActivation) modifier included in all lock functions. It also potentially allows no cap in lpETH minted and also discourages users from locking ETH in the PrelaunchPoints.sol contract before contract addresses are set (i.e. loopActivation is assigned).

Proof of Concept

Scenario 1

Bundle a transaction of donation and claiming with a previously locked position of wrapped LRT. User can execute the following in one transaction, assuming the user previously has a locked position with any of the allowed LRTs.

  1. Donate ETH directly to contract.
  2. Call claim()/claimAndStake(), claiming all tokens, this swaps users wrapped LRT to ETH via _fillQuote.
  3. Since claimedAmount is set as address(this).balance here, claimedAmountis computed as the addition of ETH receive from LRT swapped + user donated ETH.
  4. claimedAmount worth of lpETH is subsequently claimed/staked via lpETH.deposit()/lpETHVault.stake().

Scenario 2

Sandwich a call to convertAllETH by front-running to directly donate ETH and then back-running to claim lpETH via multiple lock positions.

  1. Assume user has 10 positions of ETH/WETH locked each with 1 ether with different addresses, with 100 ETH total locked.
  2. Front-run call to convertAllETH by donating 1 ETH. This sets totalLpETH to be 101 ETH as seen here.
  3. Ratio of totalLpETH : totalSupply computed here is now 1.01 (1.01).
  4. Back-run convertAllETH by executing claims for all 10 position, each claim will mint 0.01 ETH extra (1.01 lpETH).

This scenario is less likely than scenario 1 as it requires user to perfectly back-run convertAllETH() with claims, although it also breaks another invariant of a 1:1 swap.

Users that deposit ETH/WETH get the correct amount of lpETH on claim (1 to 1 conversion)

Recommended Mitigation Steps

  1. For scenario 1, set claimedAmount to amount of ETH bought from LRT swap (such as buyAmount for uniV3).
  2. For scenario 2, no fix is likely required since it would require users to risk their funds to be transferred by other users due to inflated totalLpETH : totalSupply ratio. If not, you can consider setting totalLpETH to totalSupply and allow admin to retrieve any additional ETH donated.

0xd4n1el (Loop) confirmed

Koolex (judge) increased severity to High


The original report as published on Code4rena, by 0xnev. 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 claimed amount is calculated from the contract's entire ETH balance rather than only the ETH obtained from swapping the user's locked tokens, so donated ETH is counted as part of the claim.

Impact

Users could gain lpETH without locking tokens before the contracts are set, potentially minting an uncapped amount and discouraging honest locking; scenario 2 is less likely as it requires perfect timing.

What the attacker needed

A previously locked position with an allowed LRT; ability to donate ETH directly to the contract; for scenario 2, ability to sandwich convertAllETH

The fix

For scenario 1, set the claimed amount to the ETH bought from the LRT swap rather than the contract balance; for scenario 2, no fix is likely required but setting totalLpETH to totalSupply and letting the admin retrieve extra ETH is suggested.

How it was found

  1. Have a previously locked position with an allowed LRT.
  2. Donate ETH directly to the contract.
  3. Call claim() or claimAndStake() to swap the locked LRT to ETH.
  4. The claimed amount includes the donated ETH, so more lpETH is minted than deserved.

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 smart contract has a rule that you can only deposit before certain other contracts are set up. The report shows two ways to get the reward token (lpETH) after that point anyway, by sending ETH directly to the contract and then claiming, or by timing a donation around a conversion call. This breaks the intended fairness of the deposit period.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by 0xnev

View all

2 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.