Skip to content
Business logic Audit finding Intermediate

setSymbolsPrice() can use the priceSig from a long time ago

The setSymbolsPrice function only checks that the price signature timestamp is not too far in the future, but does not check that it is recent enough. An attacker could reuse an old price signature with a large negative unrealised profit and loss value to trigger a liquidation of partyB.

Ruhum Follow with berndartmueller, bin2chen and 10 others

Originally disclosed on Sherlock

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

Found by

Ruhum, berndartmueller, bin2chen, cergyk, kutugu, libratus, mstpr-brainbot, pengun, rvierdiiev, shaka, simon135, sinarette, xiaoming90

Summary

setSymbolsPrice() only restricts the maximum value of priceSig.timestamp, but not the minimum time This allows a malicious user to choose a malicious priceSig from a long time ago A malicious priceSig.upnl can seriously harm partyB

Vulnerability Detail

setSymbolsPrice() only restricts the maximum value of priceSig.timestamp, but not the minimum time

Solidity
    function setSymbolsPrice(address partyA, PriceSig memory priceSig) internal {
        MAStorage.Layout storage maLayout = MAStorage.layout();
        AccountStorage.Layout storage accountLayout = AccountStorage.layout();
@>      LibMuon.verifyPrices(priceSig, partyA);
        require(
@>          priceSig.timestamp <=
                maLayout.liquidationTimestamp[partyA] + maLayout.liquidationTimeout,
            "LiquidationFacet: Expired signature"
        );

LibMuon.verifyPrices only check sign, without check the time range

Solidity
    function verifyPrices(PriceSig memory priceSig, address partyA) internal view {
        MuonStorage.Layout storage muonLayout = MuonStorage.layout();
        require(priceSig.prices.length == priceSig.symbolIds.length, "LibMuon: Invalid length");
        bytes32 hash = keccak256(
            abi.encodePacked(
                muonLayout.muonAppId,
                priceSig.reqId,
                address(this),
                partyA,
                priceSig.upnl,
                priceSig.totalUnrealizedLoss,
                priceSig.symbolIds,
                priceSig.prices,
                priceSig.timestamp,
                getChainId()
            )
        );
        verifyTSSAndGateway(hash, priceSig.sigs, priceSig.gatewaySignature);
    }

In this case, a malicious user may pick any priceSig from a long time ago, and this priceSig may have a large negative unpl, leading to LiquidationType.OVERDUE, severely damaging partyB

We need to restrict priceSig.timestamp to be no smaller than maLayout.liquidationTimestamp[partyA] to avoid this problem

Impact

Maliciously choosing the illegal PriceSig thus may hurt others user

Code Snippet

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

Tool used

Manual Review

Recommendation

restrict priceSig.timestamp to be no smaller than maLayout.liquidationTimestamp[partyA]

Solidity
    function setSymbolsPrice(address partyA, PriceSig memory priceSig) internal {
        MAStorage.Layout storage maLayout = MAStorage.layout();
        AccountStorage.Layout storage accountLayout = AccountStorage.layout();

        LibMuon.verifyPrices(priceSig, partyA);
        require(maLayout.liquidationStatus[partyA], "LiquidationFacet: PartyA is solvent");
        require(
            priceSig.timestamp <=
                maLayout.liquidationTimestamp[partyA] + maLayout.liquidationTimeout,
            "LiquidationFacet: Expired signature"
        );
+     require(priceSig.timestamp >= maLayout.liquidationTimestamp[partyA],"invald price timestamp");

Discussion

MoonKnightDev

Fixed code PR link: https://github.com/SYMM-IO/symmio-core/pull/22

The original report as published on Sherlock, by Ruhum. 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 contract fails to enforce a lower bound on the price signature timestamp, allowing old signatures to be reused.

Impact

A malicious user could choose an old price signature with a large negative unrealised profit and loss, potentially causing a liquidation that harms partyB.

What the attacker needed

Access to a valid old price signature

The fix

The fix is to require that the price signature timestamp is not earlier than the liquidation timestamp for partyA.

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 smart contract function that sets prices for liquidation accepts a signed price update but only checks that the timestamp is not too far in the future. It does not check that the timestamp is recent, so someone can reuse an old signed price that shows a big loss and cause an unfair liquidation.

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 Ruhum

View all

55 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.