Skip to content
Race condition Audit finding Intermediate

Vault: Withdrawals can be frontrun to cause users to burn tokens without receiving funds in return

A vault holding several stablecoins let a user withdraw in a chosen coin, so an attacker could front-run another user's withdrawal by draining that coin first. The victim's tokens would then be burned while returning little or nothing, and the attacker could later withdraw the remaining coins.

hickuphh3 Follow

Originally disclosed on Code4rena

Submitted by hickuphh3

Impact

Let us assume either of the following cases:

  1. The vault / protocol is to be winded down or migrated, where either the protocol is halted and withdrawAll() has been called on all active strategies to transfer funds into the vault.
  2. There are 0 strategies. Specifically, _controller.strategies() = 0

Attempted withdrawals can be frontrun such that users will receive less, or even no funds in exchange for burning vault tokens. This is primarily enabled by the feature of having deposits in multiple stablecoins.

Proof of Concept

  1. Assume getPricePerFullShare() of 1e18 (1 vault token = 1 stablecoin). Alice has 1000 vault tokens, while Mallory has 2000 vault tokens, with the vault holdings being 1000 USDC, 1000 USDT and 1000 DAI.
  2. Alice attempts to withdraw her deposit in a desired stablecoin (Eg. USDC).
  3. Mallory frontruns Alice’s transaction and exchanges 1000 vault tokens for the targeted stablecoin (USDC). The vault now holds 1000 USDT and 1000 DAI.
  4. Alice receives nothing in return for her deposit because the vault no longer has any USDC. getPricePerFullShare() now returns 2e18.
  5. Mallory splits his withdrawals evenly, by burning 500 vault tokens for 1000 USDT and the other 500 vault tokens for 1000 DAI.

Hence, Mallory is able to steal Alice’s funds by frontrunning her withdrawal transaction.

Recommended Mitigation Steps

The withdrawal amount could be checked against getPricePerFullShare(), perhaps with reasonable slippage.

GainsGoblin (yAxis) commented:

Duplicate of #28

GalloDaSballo (judge) commented:

Disagree with duplicate label as this shows a Value Extraction, front-running exploit. Medium severity as it’s a way to “leak value”

This can be mitigated through addressing the “Vault value all tokens equally” issue

GainsGoblin (yAxis) commented:

The issue is exactly the same as #28. Both issues present the exact same front-running example.

BobbyYaxis (yAxis) noted:

We have mitigated by deploying vaults that only accept the Curve LP token itself used in the strategy. There is no longer an array of tokens accepted. E.g Instead of a wBTC vault, we have a renCrv vault. Or instead of 3CRV vault, we have a mimCrv vault. The strategy want token = the vault token.

The original report as published on Code4rena, by hickuphh3. 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 vault valued all its stablecoins equally and paid withdrawals in a caller-chosen coin without checking the payout against the share price, so draining one coin shifted value between users.

Impact

A user could lose some or all of the value of their withdrawal, and the attacker could take it, when the vault is being wound down or has no active strategies.

What the attacker needed

Vault holds several stablecoins; withdrawal in a chosen coin; attacker can front-run the transaction

The fix

The project says it mitigated the issue by deploying vaults that accept only the single Curve LP token used by the strategy, rather than an array of tokens.

How it was found

  1. The vault holds equal amounts of three stablecoins and the share price is one vault token per stablecoin.
  2. A victim asks to withdraw their share in one chosen stablecoin.
  3. The attacker front-runs and withdraws that same stablecoin first, emptying it from the vault.
  4. The victim's withdrawal returns nothing while their vault tokens are burned.
  5. The attacker then withdraws the remaining stablecoins in even parts to collect the value.

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 vault is a shared pot of money that people pay into and later take out. Here the pot held several different stablecoins, and a person could ask to be paid back in one specific coin. An attacker watched for someone's withdrawal, took all of that coin out first, and left the victim with nothing even though their share of the pot was burned.

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 hickuphh3

View all

43 more disclosed reports, best first.

More from yAxis 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.