Skip to content
Race condition Audit finding Intermediate

vaultOwner Can Front-Run rebalance() With setAutomation() To Lower Incentives

A vault owner can front-run a keeper's rebalance call by lowering the incentive fee via setAutomation, causing the keeper to receive less reward than expected. The attacker can then restore the fee afterwards.

0xNazgul Follow

Originally disclosed on Code4rena

Submitted by 0xNazgul

https://github.com/code-423n4/2022-08-mimo/blob/main/contracts/actions/automated/MIMOAutoAction.sol#L32

https://github.com/code-423n4/2022-08-mimo/blob/main/contracts/actions/automated/MIMOAutoRebalance.sol#L54

Impact

A vaultOwner who is “not confident enough in ourselves to stay up-to-date with market conditions to know when we should move to less volatile collateral to avoid liquidations.” They can open their vault to other users who pay attention to the markets and would call rebalance to receive the incentivized fees. The vaultOwner who doesn’t want to pay the baiting high fees instead front-runs the autoRebalance() with setAutomation() to lower incentives.

Proof of Concept

  1. Mallory, a vaultOwner isn’t confident in staying up-to-date with market conditions. She has her vault setup to be automated and has high fee incentives.
  2. Alice, a user who is confident in staying up-to-date with market conditions see’s a profitable opportunity and calls rebalance().
  3. Mallory is confident in her programing and watching mempools for when rebalance() is called. See’s that Alice just called rebalance() and calls setAutomation() to lower the incentives.
  4. Alice’s call to rebalance() then goes through getting lower incentives and Mallory then calls setAutomation() to set the incentives back to normal.

Recommended Mitigation Steps

Add a time-lock to setAutomation so that the vaultOwner can’t front-run users.

RnkSngh (Mimo) confirmed and commented:

We confirm that this is an issue and intend to implement a fix.

horsefacts (warden) reviewed mitigation:

Status: 👍 Acknowledged

Finding: A warden identified that a malicious vault owner could frontrun automated calls to MIMOAutoRebalance#rebalance and reconfigure their automated vault with a reduced incentive fee.

What changed: The Mimo team have acknowledged the finding.

Acknowledgement:

We’ve decided against fixing this in the end. The only potential loser is a keeper/automator that gets frontrun and does not get the reward they thought they would get and thus paid a gas fee that was not covered by the reward. We feel keepers are advanced enough to hide their txs from the mempool and that they’re also smart enough to let the tx revert if it does not yield a profit. For legit users of the protocol this has no impact whatsoever IMO. We also feel a timelock wouldn’t have been enough of a mitigation and might hurt legitimate use of the protocol.


The original report as published on Code4rena, by 0xNazgul. 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 setAutomation function has no time delay, allowing the vault owner to change incentives immediately before a rebalance transaction is mined.

Impact

A keeper could receive a lower reward than expected and may pay a gas fee that is not covered by the reward; the protocol stated this has no impact on legitimate users.

What the attacker needed

Vault owner controls automation settings; attacker can watch mempool; keeper calls rebalance

The fix

The project decided against fixing this, stating that a timelock would not be sufficient and might hurt legitimate use.

How it was found

  1. Mallory sets up her vault with high fee incentives for automation.
  2. Alice sees a profitable opportunity and calls rebalance().
  3. Mallory watches the mempool, sees Alice's rebalance call, and calls setAutomation() to lower the incentives.
  4. Alice's rebalance() executes with lower incentives, and Mallory then calls setAutomation() to restore the incentives.

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 owner sets a fee to reward anyone who rebalances their vault. A keeper watches for this and calls rebalance to earn the fee. The owner can see the keeper's transaction in the waiting area (mempool) and quickly change the fee to a lower amount before the keeper's transaction is processed, so the keeper earns less.

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 0xNazgul

View all

6 more disclosed reports, best first.

More from Mimo DeFi 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.