Skip to content
Business logic Audit finding Intermediate

Strategists are paid 10x the vault fee because of a math error

The vault fee is stored in basis points but the fee calculation divides by 1,000 instead of 10,000, so strategists receive ten times the intended fee. An attacker who is a strategist could take a much larger share of payments made to the vault.

obront Follow

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2022-10-astaria-judging/issues/49

Found by

obront

Summary

Strategists set their vault fee in BPS (x / 10,000), but are paid out as x / 1,000. The result is that strategists will always earn 10x whatever vault fee they set.

Vulnerability Detail

Whenever any payment is made towards a public vault, beforePayment() is called, which calls _handleStrategistInterestReward().

The function is intended to take the amount being paid, adjust by the vault fee to get the fee amount, and convert that amount of value into shares, which are added to strategistUnclaimedShares.

Solidity
function _handleStrategistInterestReward(uint256 lienId, uint256 amount)
    internal
    virtual
    override
  {
    if (VAULT_FEE() != uint256(0)) {
      uint256 interestOwing = LIEN_TOKEN().getInterest(lienId);
      uint256 x = (amount > interestOwing) ? interestOwing : amount;
      uint256 fee = x.mulDivDown(VAULT_FEE(), 1000);
      strategistUnclaimedShares += convertToShares(fee);
    }
  }

Since the vault fee is stored in basis points, to get the vault fee, we should take the amount, multiply it by VAULT_FEE() and divide by 10,000. However, we accidentally divide by 1,000, which results in a 10x larger reward for the strategist than intended.

As an example, if the vault fee is intended to be 10%, we would set VAULT_FEE = 1000. In that case, for any amount paid off, we would calculate fee = amount * 1000 / 1000 and the full amount would be considered a fee for the strategist.

Impact

Strategists will be paid 10x the agreed upon rate for their role, with the cost being borne by users.

Code Snippet

https://github.com/sherlock-audit/2022-10-astaria/blob/main/src/PublicVault.sol#L513-L524

Tool used

Manual Review

Recommendation

Change the 1000 in the _handleStrategistInterestReward() function to 10_000.

Discussion

IAmTurnipBoy

Escalate for 1 USDC

Don't agree with high severity. Fee can easily be changed by protocol after the fact to fix this, which is why medium makes more sense. Simple to fix as a parameter change.

sherlock-admin

Escalate for 1 USDC

Don't agree with high severity. Fee can easily be changed by protocol after the fact to fix this, which is why medium makes more sense. Simple to fix as a parameter change.

You've created a valid escalation for 1 USDC!

To remove the escalation from consideration: Delete your comment. To change the amount you've staked on this escalation: Edit your comment (do not create a new comment).

You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final.

Evert0x

Escalation accepted.

sherlock-admin

Escalation accepted.

This issue's escalations have been accepted!

Contestants' payouts and scores will be updated according to the changes made on this issue.

zobront

Escalate for 5 USDC

VAULT_FEE() is set as an immutable arg when vault is deployed using ClonesWithImmutableArgs. There is no ability to change it later as the escalation claims. This value would be hard coded in all vaults created.

The result is that vault strategists would be given all of the funds of users who deposit in their vault, irretrievably stealing funds from users of the protocol. This is definitely a high.

sherlock-admin

Escalate for 5 USDC

VAULT_FEE() is set as an immutable arg when vault is deployed using ClonesWithImmutableArgs. There is no ability to change it later as the escalation claims. This value would be hard coded in all vaults created.

The result is that vault strategists would be given all of the funds of users who deposit in their vault, irretrievably stealing funds from users of the protocol. This is definitely a high.

You've created a valid escalation for 5 USDC!

To remove the escalation from consideration: Delete your comment. To change the amount you've staked on this escalation: Edit your comment (do not create a new comment).

You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final.

Evert0x

Escalation accepted

sherlock-admin

Escalation accepted

This issue's escalations have been accepted!

Contestants' payouts and scores will be updated according to the changes made on this issue.

The original report as published on Sherlock, by obront. 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

The fee calculation divides by 1,000 instead of 10,000, even though the fee is stored in basis points (where 10,000 represents 100%).

Impact

Strategists are paid ten times the agreed rate, with the extra cost borne by users; the fee is immutable so it cannot be corrected after deployment.

What the attacker needed

A public vault with a non-zero fee; a strategist role on that vault

The fix

The divisor in the fee calculation should be changed from 1,000 to 10,000.

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 fee is meant to be a small percentage of the money paid into a vault, given to the person who runs it. The code used the wrong number when working out that percentage, so the person running the vault got ten times more than they should. This means users of the vault lost more of their money than agreed.

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 obront

View all

46 more disclosed reports, best first.

More from Astaria

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.