Skip to content
Race condition Write-up Advanced

Sherlock Yield Strategy

A cross-protocol reentrancy flaw in Sherlock's Euler yield strategy allowed an attacker to manipulate Euler's exchange rate during a 1inch swap callback, causing Sherlock to overvalue its shares and redeem more USDC than deserved. The exploit required locking millions in Sherlock for six months and accessing billions in flash loans, but could have drained a material amount of the staking pool.

mirror.xyz

Published on mirror.xyz

Sherlock's EulerStrategy.balanceOf() (which uses the result of the balanceOfUnderlying() call on Euler's eUSDC contract) can be manipulated in Euler's eUSDC contract, by first manipulating the exchangeRate in Euler, since balanceOfUnderlying = shares exchangeRate.

The author, on mirror.xyz

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Euler's balanceOfUnderlying() can return an inflated value during a 1inch swap callback because the deposit is not yet processed, so totalAssets increases while totalBalances remains unchanged, and Sherlock's strategy used this value without checking for reentrancy.

Impact

The exploit could have resulted in a material amount of Sherlock's staking pool being drained, but it required a six-month lockup, billions in flash loans, and specific market conditions, and no funds were immediately at risk.

What the attacker needed

5M+ USDC staked for 6 months; Access to ~1Bn USDC in flash loans; Specific market conditions

The fix

The fix was to make certain Euler view functions revert if called during a reentrancy lock, preventing the inflated balance from being read during the swap callback.

How it was found

  1. Stake a large amount of USDC in Sherlock for at least six months.
  2. Donate eUSDC to the EulerStrategy to increase Sherlock's exposure to Euler.
  3. Deposit ETH and USDC into Euler to create a position for the swap.
  4. Call swap1Inch with a small swap, setting the receiver to the attacker's contract.
  5. In the 1inch callback, transfer a large amount of USDC directly to Euler to inflate the exchange rate.
  6. Redeem the Sherlock shares at the inflated rate, then withdraw the deposited funds from Euler.

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 write-up has not been written yet. The Original tab links to the source.

Sherlock put user funds into Euler, a lending protocol, to earn interest. When someone withdrew from Sherlock, the code asked Euler how much the investment was worth. An attacker found a way to temporarily make Euler report a higher value by sending extra funds during a swap, so Sherlock paid out too much. This only worked if the attacker first locked up a large sum for six months and could borrow a huge amount temporarily.

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.

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.