If long and short products has different maker fees, vault rebalance can be spammed to eat vaults balance
The vault's rebalancing logic does not account for maker fees when long and short products have different fees, so repeated rebalancing can gradually deplete the vault's collateral. An attacker could force rebalancing to generate maker fees at the vault's expense.
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2023-05-perennial-judging/issues/41
Found by
mstpr-brainbot
Summary
In a market scenario where long and short products carry different position fees, continuous rebalancing could potentially deplete the vault's funds. This situation arises when closing positions incurs a maker fee, which gradually eats away at the collateral balance. The rebalancing cycle continues until the fee becomes insignificant or the collateral balance is exhausted.
Vulnerability Detail
If a market's long and short products have different position fees, continuous rebalancing could be an issue. A significant position fee difference might deplete all funds after repeated rebalancing.
Consider a scenario with one market, where the long product has a 0% maker fee (position fee), and the short product a 10% maker fee. A vault holding 100 positions divided across these markets, with 50 short and 50 long positions, and collateral balances of 50-50 each, is presented.
Now, suppose the vault and the product are entirely in sync (meaning they're of the same version). If someone deposits 100 assets into the vault, it would distribute that deposit, adding 50 to both product's collateral balances, bringing them to 100 each. The vault then increases its position to 100 to maintain the 1x leverage. The long market would match this since it has no maker fee, but the short market would lose 5 from its collateral due to the fee charged by the openMake operation. As a result, the market now has 95 in the short market and 100 in the long market collateral. This imbalance triggers a rebalancing operation via sync().
After the second call to sync(), the collateral balances would be 97.5 in both markets, and the markets would reduce their positions to maintain the 1x leverage. The long market would reduce its position to 97.5, but when the short market does the same, the closeMake operation's fee charge reduces the short market collateral by 0.25, resulting in final balances of 97.5 in the long market and 97.25 in the short market. This imbalance again allows a call to settle...
As seen if the difference between the products are high the rebalance will start eating the vaults collateral balance by paying redundant maker fees.
The above scenario assumes only one market with two products. If there are two markets, the situation could be more troublesome due to the additional fee charges and potentially higher losses.
Impact
Since the vaults funds can be drained significantly if certain cases are met (high makerFee set by market owner and big collateral balance differences between markets or directional exposure on vault causing the collateral balance differences higher than usual so more funds to rebalance hence more fee to pay). I'll label it as high.
Code Snippet
Tool used
Manual Review
Recommendation
Consider accounting the positionFee if there are any on any of the markets or assert that both of the markets has the same positionFee.
Discussion
arjun-io
This is a good call - currently vault's don't support handling maker fees in a clean way. We probably won't fix this in the current version of the vaults but it's something we'd likely address in the future as maker fees might become necessary in certain markets
mstpr
Escalate for 10 USDC
I think this is a valid high since it can drain the vaults balance significantly.
As stated in the impact section of the issue, if the price movement to one side is high, there will be a difference between the vaults short and long products collateral balance hence, the more fee to apply. Therefore, calling rebalancing few more times will result in more losses and this will start taking the funding fees that the vault generating. Although at some point it will converge to very small numbers, this will lead to loss of funds for the vault depositors.
sherlock-admin
Escalate for 10 USDC
I think this is a valid high since it can drain the vaults balance significantly.
As stated in the impact section of the issue, if the price movement to one side is high, there will be a difference between the vaults short and long products collateral balance hence, the more fee to apply. Therefore, calling rebalancing few more times will result in more losses and this will start taking the funding fees that the vault generating. Although at some point it will converge to very small numbers, this will lead to loss of funds for the vault depositors.
You've created a valid escalation for 10 USDC!
To remove the escalation from consideration: Delete your comment.
You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final.
KenzoAgada
Hmm... I think there is a case for this to be high severity as this will result in a continuous eating up of user funds, if vaults for products with maker fees are launched. On the other hand, Perennial doesn't have any products with maker fees at the moment, and so Perennial says that this current iteration of vaults was intentionally not including the handling of that.
arjun-io
Similar to #43 this is intended as the added complexity to support something that wasn't likely to be turned on wasn't worth it. These two can likely be judged similarly, although I will say for this issue there is a malicious attack vector where other makers can force the vault to rebalance and thus generate maker fees which they get a cut of, this would necessitate quicker action to add some sort of rebalance/vault fee
jacksanford1
Seems like there's a chance that a significant amount of funds could be lost due to coordinated effort here.
There are enough contingencies to make it a Medium:
high makerFee set by market owner and big collateral balance differences between markets or directional exposure on vault causing the collateral balance differences higher than usual so more funds to rebalance hence more fee to pay
And enough of a risk of material funds being lost in a coordinated attack scenario.
jacksanford1
Result: Medium Unique See previous comment.
sherlock-admin2
Escalations have been resolved successfully!
Escalation status:
- mstpr: rejected
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's rebalancing logic does not account for maker fees, so when long and short products have different fees, each rebalance incurs a fee that reduces collateral.
Impact
The vault's funds could be significantly drained if maker fees are high and collateral imbalances are large, and other makers could force rebalancing to generate fees at the vault's expense.
What the attacker needed
Market with different maker fees for long and short; vault with collateral imbalance; attacker can trigger rebalancing
The fix
The vault should account for position fees or assert that both markets have the same position fee.
How it was found
- A vault holds positions in a market where long and short products have different maker fees.
- A deposit causes the vault to open positions, and the short product charges a maker fee, creating a collateral imbalance.
- The vault calls sync() to rebalance, which closes part of the short position and incurs another maker fee, reducing collateral further.
- Repeated rebalancing continues to charge fees, gradually depleting the vault's collateral.
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 money and tries to keep equal long and short positions. If opening or closing a position costs a fee, and the two sides have different fees, then each time the vault rebalances it pays a fee. Over many rebalances, these fees add up and reduce the vault's money.
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.