Skip to content
Business logic Audit finding Intermediate

Vault.claim should be called before `pushTotalUnderlyingToController`

The vault's total underlying amount is pushed to the controller without first claiming earned reward tokens, so the reported balance and exchange rate omit those funds. This makes the amount sent to the controller inaccurate and the exchange rate too low.

Ch_301 Follow with rvierdiiev

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2023-01-derby-judging/issues/123

Found by

Ch_301, rvierdiiev

Summary

Vault.claim should be called before pushTotalUnderlyingToController.

Vulnerability Detail

Every cycle, each vault should send it's total underlying amount to xController, so xController can calculate according to new allocations, which amount of underlying vault should receive from/send to xController. Also it calculates exchangeRate that will be used fro new depositors/withdrawers.

MainVault.pushTotalUnderlyingToController is responsible for sending underlying amount. It first calls setTotalUnderlying function, which will calculate amount of underlying inside all active providers. And then it will calculate total amount by adding funds controlled by vault without reserved funds amount. uint256 underlying = savedTotalUnderlying + getVaultBalance() - reservedFunds; Then this amount is sent to xController.

Now let's check another function Vault.claimTokens which is called inside rebalance function. The purpose of this function is to receive earned rewards tokens from providers and then swap them to vaultCurrency token.

Of course, this increases getVaultBalance().

So the main point of this bug is that Vault.claim should be called inside pushTotalUnderlyingToController as this is also funds that should be then distributed among vaults according to allocations and it should also increased exhangeRate.

Impact

Underlying amount sent to xController is not accurate, actually vault can have more funds. Exhange rate is also not accurate.

Code Snippet

Provided above

Tool used

Manual Review

Recommendation

Call Vault.claim inside pushTotalUnderlyingToController.

The original report as published on Sherlock, by Ch_301. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

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 function that reports the vault's total underlying balance does not first claim and convert pending reward tokens, so the reported balance excludes those funds.

What the attacker needed

Vault has unclaimed reward tokens

The fix

The vault should call its claim function inside pushTotalUnderlyingToController so reward tokens are collected and converted before the total is reported.

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 holds user money and also earns reward tokens from other places. Before telling the central controller how much money it has, the vault should first collect those rewards and swap them into the main currency. Because it skips that step, the controller sees a smaller number than the vault really holds, which affects how much each person's share is worth.

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 Ch_301

View all

39 more disclosed reports, best first.

More from Derby

View all

The newest disclosed reports for this program.

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.