Skip to content
Business logic Audit finding Intermediate

Imbalanced approach of distributing the liquidation fee within `setSymbolsPrice` function

The setSymbolsPrice function only records the first liquidator who calls it, so a malicious liquidator can call it with minimal symbol prices and still receive the full liquidation fee. This leaves the liquidation incomplete and disincentivises others from finishing, potentially forcing the counterparty to complete the process at their own cost.

0xGoodess Follow with PokemonAuditSimulator, Yuki and 4 others

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2023-06-symmetrical-judging/issues/231

Found by

0xGoodess, PokemonAuditSimulator, Yuki, cergyk, kutugu, rvierdiiev, xiaoming90

Summary

The imbalance approach of distributing the liquidation fee within setSymbolsPrice function could be exploited by malicious liquidators to obtain the liquidation fee without completing their tasks and maximizing their gains. While doing so, it causes harm or losses to other parties within the protocols.

Vulnerability Detail

A PartyA can own a large number of different symbols in its portfolio. To avoid out-of-gas (OOG) errors from occurring during liquidation, the setSymbolsPrice function allows the liquidators to inject the price of the symbols in multiple transactions instead of all in one go.

Assume that the injection of the price symbols requires 5 transactions/rounds to complete and populate the price of all the symbols in a PartyA's portfolio. Based on the current implementation, only the first liquidator that calls the setSymbolsPrice will receive the liquidation fee. Liquidators that call the setSymbolsPrice function subsequently will not be added to the AccountStorage.layout().liquidators[partyA] listing as Line 88 will only be executed once when the liquidationType is still not initialized yet.

https://github.com/sherlock-audit/2023-06-symmetrical/blob/main/symmio-core/contracts/facets/liquidation/LiquidationFacetImpl.sol#L34

Solidity
File: LiquidationFacetImpl.sol
34:     function setSymbolsPrice(address partyA, PriceSig memory priceSig) internal {
..SNIP..
56:         if (accountLayout.liquidationDetails[partyA].liquidationType == LiquidationType.NONE) {
57:             accountLayout.liquidationDetails[partyA] = LiquidationDetail({
58:                 liquidationType: LiquidationType.NONE,
59:                 upnl: priceSig.upnl,
60:                 totalUnrealizedLoss: priceSig.totalUnrealizedLoss,
61:                 deficit: 0,
62:                 liquidationFee: 0
63:             });
..SNIP..
88:             AccountStorage.layout().liquidators[partyA].push(msg.sender);
89:         } else {
90:             require(
91:                 accountLayout.liquidationDetails[partyA].upnl == priceSig.upnl &&
92:                     accountLayout.liquidationDetails[partyA].totalUnrealizedLoss ==
93:                     priceSig.totalUnrealizedLoss,
94:                 "LiquidationFacet: Invalid upnl sig"
95:             );
96:         }
97:     }

A malicious liquidator could take advantage of this by only setting the symbol prices for the first round for each liquidation happening in the protocol. To maximize their profits, the malicious liquidator would call the setSymbolsPrice with none or only one (1) symbol price to save on the gas cost. The malicious liquidator would then leave it to the others to complete the rest of the liquidation process, and they will receive half of the liquidation fee at the end of the liquidation process.

Someone would eventually need to step in to complete the liquidation process. Even if none of the liquidators is incentivized to complete the process of setting the symbol prices since they will not receive any liquidation fee, the counterparty would eventually have no choice but to step in to perform the liquidation themselves. Otherwise, the profits of the counterparty cannot be realized. At the end of the day, the liquidation will be completed, and the malicious liquidator will still receive the liquidation fee.

Impact

Malicious liquidators could exploit the liquidation process to obtain the liquidation fee without completing their tasks and maximizing their gains. While doing so, many liquidations would be stuck halfway since it is likely that no other liquidators will step in to complete the setting of the symbol prices because they will not receive any liquidation fee for doing so (not incentivized).

This could potentially lead to the loss of assets for various parties:

  • The counterparty would eventually have no choice but to step in to perform the liquidation themselves. The counterparty has to pay for its own liquidation, even though it has already paid half the liquidation fee to the liquidator.
  • Many liquidations would be stuck halfway, and liquidation might be delayed, which exposes users to greater market risks, including the risk of incurring larger losses or having to exit at an unfavorable price.

Code Snippet

https://github.com/sherlock-audit/2023-06-symmetrical/blob/main/symmio-core/contracts/facets/liquidation/LiquidationFacetImpl.sol#L34

Tool used

Manual Review

Recommendation

Consider a more balanced approach for distributing the liquidation fee for liquidators that calls the setSymbolsPrice function. For instance, the liquidators should be compensated based on the number of symbol prices they have injected.

If there are 10 symbols to be filled up, if Bob filled up 4 out of 10 symbols, he should only receive 40% of the liquidation fee. This approach has already been implemented within the liquidatePartyB function via the partyBPositionLiquidatorsShare variable. Thus, the same design could be retrofitted into the setSymbolsPrice function.

Discussion

MoonKnightDev

In the current system setup, we have established a role for liquidators. To give them this role, we might require an external contract in which they are obliged to lock a certain amount of money. This serves as a guarantee against any potential system sabotage or incomplete liquidation they may commit. If they fail to fulfill their role appropriately, they would face penalties.

hrishibhat

@xiaoming9090 Based on the above comment there are no restrictions applied on liquidators currently and there is the possibility of malicious actions by the liquidator, correct?

hrishibhat

Considering this issue as a valid medium, although the liquidator role is an external role and is restricted, it is still granted by the protocol.

Navid-Fkh

We don't consider this to be an issue in the system for two obvious reasons:

  1. The liquidator has an incentive to complete the process in order to claim their LF.
  2. Malicious liquidators can be easily identified and punished. Given that we have defined a liquidator role, it's probable that they have locked funds with us as a prerequisite for that role

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

Impact

Malicious liquidators could obtain the liquidation fee without completing their tasks, and many liquidations could be stuck halfway, potentially causing losses to the counterparty and delaying liquidation.

What the attacker needed

Liquidator role; multiple symbols in PartyA portfolio

The fix

The liquidation fee should be distributed proportionally based on the number of symbol prices each liquidator injects, similar to the existing partyBPositionLiquidatorsShare mechanism.

How it was found

  1. A malicious liquidator calls setSymbolsPrice with none or only one symbol price to save gas.
  2. The liquidator is recorded as the fee recipient because the liquidation type is still NONE.
  3. Other liquidators are not incentivised to complete the remaining symbol price injections since they will not receive the fee.
  4. The counterparty is eventually forced to complete the liquidation themselves, while the malicious liquidator still receives the fee.

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.

In this system, liquidators are people who step in to close out risky trading positions and earn a fee for doing so. The code only pays the first person who starts the multi-step price-setting process, even if they do almost none of the work. That means someone can grab the fee with minimal effort and leave the rest of the job to others.

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

View all

13 more disclosed reports, best first.

More from Symmetrical Update

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.