Force Close can be DOSed by exploiting `settleUpnl` function
PartyB can abuse the settleUpnl function to increment nonces, causing PartyA's forceClosePosition transaction to revert. This allows PartyB to prevent PartyA from force-closing positions, potentially avoiding losses.
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2024-09-symmio-v0-8-4-update-contest-judging/issues/42
Found by
xiaoming90
Summary
PartyB can abuse the newly implemented settleUpnl function to increment the nonce to block PartyA's force close action.
Root Cause
- A
SettlementSigsignature withquotesSettlementsDataand/orpartyBsarray being empty can be passed intosettleUpnlfunction - No cooldown if PartyB is settling its own positions
- No minimum PnL to be settled (Even 1 wei of PnL can be settled)
Internal pre-conditions
No response
External pre-conditions
No response
Attack Path
This report is similar to the report from the previous contest, but with a different attack vector.
Assume that PartyA requests to close a quote via requestToClosePosition function. If PartyB does not respond within the cooldown period, PartyA can call the PartyAFacetImpl.forceClosePosition to close the quote forcefully.
Within the forceClosePosition function:
- In Line 86 below, the
verifyHighLowPricefunction will verify that the signature is valid. The function will use the nonce of PartyA and PartyB to generate the hash. - In Line 88 below, the
verifySettlementfunction verifies that the signature is valid. Similarly, it also relies on the nonce of PartyA and PartyB to generate the hash.
File: ForceActionsFacetImpl.sol
51: function forceClosePosition(
52: uint256 quoteId,
53: HighLowPriceSig memory sig,
54: SettlementSig memory settlementSig,
55: uint256[] memory updatedPrices
56: ) internal returns (uint256 closePrice, bool isPartyBLiquidated, int256 upnlPartyB, uint256 partyBAllocatedBalance) {
..SNIP..
86: LibMuonForceActions.verifyHighLowPrice(sig, quote.partyB, quote.partyA, quote.symbolId);
87: if (updatedPrices.length > 0) {
88: LibMuonSettlement.verifySettlement(settlementSig, quote.partyA);
89: }
Attack Path 1 - Incrementing PartyA's nonce
The following describes the attack path:
- At this point, PartyA's nonce is 200. PartyA fetches the signatures from Muon and bundles them with the
forceClosePositiontransaction, and submits to the mempool to close the quote forcefully as PartyB did not respond to PartyA's close request for an extended period. - PartyB front-run PartyA's transaction and exploit the new
settleUpnlfunction to increment its nonce to 201. - When PartyA's transaction gets executed, since the signature's PartyA nonce is 200, while the PartyA's nonce on-chain is 201, the transaction will revert.
- Party B could continuously grieve Party A, preventing them from being forced to close their positions.
There are several ways that PartyB can increment the PartyA's nonce via the settleUpnl function with no cost or minimum cost:
- Passing a
SettlementSigsignature withquotesSettlementsDataand/orpartyBsarray being empty. In this case, the code at Line 34 will increment PartyA's nonce, but the rest of the code that involves the for-loop will be bypassed since the array (settleSig.quotesSettlementsData.length = 0) is empty
File: LibSettlement.sol
15: function settleUpnl(
16: SettlementSig memory settleSig,
..SNIP..
34: accountLayout.partyANonces[partyA] += 1;
..SNIP..
40: for (uint8 i = 0; i < settleSig.quotesSettlementsData.length; i++) {
- The tricks mentioned in "Attack Path 2" section below for incrementing PartyB's nonce can also be applied here to increment PartyA's nonce. Refer to the next section for more details.
Attack Path 2 - Incrementing PartyB's nonce
The following describes the attack path:
- At this point, PartyB's nonce is 800. PartyA fetches the signatures from Muon and bundles them with the
forceClosePositiontransaction, and submits to the mempool to close the quote forcefully as PartyB did not respond to PartyA's close request for an extended period. - PartyB front-run PartyA's transaction and exploit the new
settleUpnlfunction to increment its nonce to 801. - When PartyA's transaction gets executed, since the signature's PartyB nonce is 800, while the PartyB's nonce on-chain is 801, the transaction will revert.
- Party B could continuously grieve Party A, preventing them from being forced to close their positions.
There are several ways that PartyB can increment its own nonce via the settleUpnl function with no cost or minimum cost:
- PartyA is permissionless. PartyB can create a PartyA account and open some dummy positions with its account. When PartyB needs to increment its nonce, simply settle a minimum possible PnL between these two accounts. There is no cooldown since PartyB is settling its own positions.
- If PartyB already has existing positions, PartyB can settle a minimum possible PnL on these positions. There is no cooldown since PartyB is settling its own positions.
Impact
This impact is the same as the impact of a report in the previous Symm IO contest. Thus, the risk rating should be aligned to Medium.
PartyB can take advantage of it against PartyA, making themselves always profitable. For instance:
- If the current price goes for PartyB, then the quote is closed, and PartyB makes a profit.
- If the current price goes against PartyB, PartyB can front-run
forceClosePositionand callsettleUpnlto increase PartyA's nonces. In this way, PartyA'sforceClosePositionwill inevitably revert because the nonces are incorrect.
In addition, when PartyA cannot close its position promptly, it exposes PartyA to unnecessary market risks and potential losses and gives PartyB an unfair advantage by giving PartyB an opportunity to turn the table (e.g., loss -> profit).
PoC
No response
Mitigation
Consider implementing the following measures to mitigate the root causes:
- Ensure that
SettlementSigsignature withquotesSettlementsDataand/orpartyBsarray being empty are rejected withinsettleUpnlfunction - Implement some cooldown even if PartyB is settling its own positions
- Implement a minimum PnL to be settled so that no one can attempt to abuse the settle upnl feature by only settling 1 wei or small amount of PnL
Discussion
sherlock-admin2
The protocol team fixed this issue in the following PRs/commits: https://github.com/SYMM-IO/protocol-core/pull/58
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 settleUpnl function allows incrementing nonces with empty settlement data and without cooldown or minimum PnL, enabling cheap nonce manipulation.
Impact
PartyB can prevent PartyA from force-closing positions, exposing PartyA to market risks and giving PartyB an unfair advantage.
What the attacker needed
PartyA has an open quote; PartyB is unresponsive; PartyB can front-run transactions
The fix
The protocol team fixed this issue in a pull request.
How it was found
- PartyA requests to close a quote via requestToClosePosition.
- PartyB does not respond within the cooldown period.
- PartyA fetches signatures from Muon and submits forceClosePosition to the mempool.
- PartyB front-runs PartyA's transaction and calls settleUpnl to increment its nonce.
- PartyA's transaction reverts because the signature's nonce no longer matches the on-chain nonce.
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 smart contract system, two parties (PartyA and PartyB) trade with each other. If PartyB stops responding, PartyA can force-close the trade, but this requires a signature that includes a number (nonce) that must match the current on-chain nonce. PartyB can repeatedly increase the nonce by calling a function called settleUpnl, so when PartyA tries to force-close, the nonce is wrong and the transaction fails. This lets PartyB block PartyA from closing the trade.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.