Skip to content
Race condition Audit finding Intermediate

Vader.redeemToMember() vulnerable to front running

The Vader contract's redeemToMember function allows any caller to redeem the entire USDV balance to an arbitrary member address. An attacker can front-run a victim's redemption call and redirect the redeemed USDV to themselves.

Vader Protocol contest

Originally disclosed on Code4rena

The USDV balance of the Vader contract is vulnerable to theft through the Vader.redeemToMember() function. A particular case is through USDV redemption front-running. Users can redeem USDV for Vader through the USDV.redeemForMember() function or the Vader.redeemToMember() function. In the case of Vader.redeemToMember(), a user would need to send their USDV to the contract before redemption. However, as this process does not happen in a single call, the victim’s call is vulnerable to front running and could have their redeemed USDV stolen by an attacker.

User’s redeem USDV could be stolen by an attacker front running their Vader.redeemToMember() call.

The steps are as follows:

  1. User sends USDV to Vader contract to be redeemed
  2. User calls Vader.redeemToMember()
  3. The Vader.redeemToMember() call is detected by an attacker, who front-runs the call by calling Vader.redeemToMember() specifying their own address as the member parameter.
  4. The full USDV balance of the Vader contract is redeemed and sent to the attacker.

Note that while this particular case is front running a redemption call, any USDV balance could be stolen in this manner. Please find the POC showing the above steps here: https://gist.github.com/toastedsteaksandwich/39bfed78b21d7e6c02fe13ea5b2023c3

Recommend that the Vader.redeemToMember() function should be restricted so that only the USDV contract can call it. Moreover, the amount parameter from USDV.redeem() or USDV.redeemForMember() should also be passed to Vader.redeemToMember() to avoid the need to sweep the entire USDV balance. In this way, the member’s redemption happens in a single tx, and would only be allocated as much Vader as redeemed in USDV.

strictly-scarce (vader) disputed:

Vader complies with a monetary security policy of “money in, money out”. Contracts will only send out funds if they are first sent funds.

This is the case for the entire system, not just Vader.redeemToMember(), such as swaps and adding liquidity. Vader is not designed to be interacted with directly, it should be wrapped. In this case, users should convert and redeem only thru the USDV contract, which first sends funds.

Incidentally this is the same mechanism that uniswap employs for withdrawing liquidity, or syncing funds to balances. You can also get front-runned if you do it in two tx, it should be wrapped in 1 tx.

Mervyn853 commented:

Our decision matrix for severity:

0: No-risk: Code style, clarity, off-chain monitoring (events etc), exclude gas-optimisations 1: Low Risk: UX, state handling, function incorrect as to spec 2: Funds-Not-At-Risk, but can impact the functioning of the protocol, or leak value with a hypothetical attack path with stated assumptions, but external requirements 3: Funds can be stolen/lost directly, or indirectly if a valid attack path shown that does not have handwavey hypotheticals.

Recommended: 0

The original report as published on Code4rena. 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 redeemToMember function lacks access control and does not tie the redemption to the caller or a specific amount, allowing anyone to sweep the contract's entire USDV balance to any address.

Impact

A user's redeemed USDV could be stolen by an attacker front-running their redemption call; the project disputed this, stating that direct interaction is not intended and users should redeem through the USDV contract.

What the attacker needed

Victim sends USDV to Vader contract; attacker can front-run transactions

The fix

The redeemToMember function should be restricted so only the USDV contract can call it, and the redemption amount should be passed through so only the redeemed amount is allocated.

How it was found

  1. User sends USDV to the Vader contract to be redeemed.
  2. User calls Vader.redeemToMember().
  3. Attacker detects the call and front-runs it by calling Vader.redeemToMember() with their own address as the member parameter.
  4. The full USDV balance of the Vader contract is redeemed and sent to the attacker.

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 holds funds that users can redeem. The redemption function does not check who is calling it, so anyone can trigger it and specify where the redeemed funds should go. An attacker watches for a victim's redemption and quickly submits their own call first, taking the funds.

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 from Vader Protocol 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.