Skip to content
Access control Audit finding Intermediate

Unauthorized PartyB could settle PNL of other PartyBs and users in the system

The settleUpnl function lacked a notPartyB modifier, so a removed PartyB with residual open positions could still settle other PartyBs' unrealised profit and loss, potentially forcing them to realise losses at unfavourable times.

xiaoming90 Follow

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2024-09-symmio-v0-8-4-update-contest-judging/issues/40

Found by

xiaoming90

Summary

The settleUpnl function does not include notPartyB modifier. As a result, unauthorized PartyB could settle PNL of other PartyBs and users in the system, causing disruption and breaking core protocol functionality. Unauthorized PartyB can prematurely settle PartyB's (victim) positions prematurely at times that are disadvantageous to PartyB, resulting in asset loss for them.

For example, in a highly volatile market, if PartyB’s positions temporarily incur a loss due to sudden market fluctuations, the Unauthorized PartyB could immediately settle these positions before the market has a chance to recover. This premature settlement forces PartyB to realize losses that might have otherwise been avoided if the positions had remained open.

Root Cause

  • The settleUpnl function does not include notPartyB modifier.

Internal pre-conditions

No response

External pre-conditions

No response

Attack Path

The settleUpnl function can only be accessed by PartyB, as per the comment below. However, the function is not guarded by the notPartyB modifier.

https://github.com/sherlock-audit/2024-09-symmio-v0-8-4-update-contest/blob/main/protocol-core/contracts/facets/Settlement/SettlementFacet.sol#L26

Solidity
File: SettlementFacet.sol
16: 	/**
17: 	 * @notice Allows Party B to settle the upnl of party A position for the specified quotes.
18: 	 * @param settlementSig The data struct contains quoteIds and upnl of parties and market prices
19: 	 * @param updatedPrices New prices to be set as openedPrice for the specified quotes.
20: 	 * @param partyA Address of party A
21: 	 */
22: 	function settleUpnl(
23: 		SettlementSig memory settlementSig,
24: 		uint256[] memory updatedPrices,
25: 		address partyA
26: 	) external whenNotPartyBActionsPaused notLiquidatedPartyA(partyA) {
27: 		uint256[] memory newPartyBsAllocatedBalances = SettlementFacetImpl.settleUpnl(settlementSig, updatedPrices, partyA);
..SNIP..
35: 	}

Instead, it depends on the quoteLayout.partyBOpenPositions[msg.sender][partyA].length > 0 at Line 31 below, which is not a reliable method to determine whether the caller is a valid PartyB. The reason is that it is possible that a PartyB (e.g., one that might be removed due to malicious activities) that has already been removed from the system still has residual open positions. In this case, the position's length check will pass, and the unauthorized PartyB could continue to settle the PNL of other PartyBs and users in the system.

https://github.com/sherlock-audit/2024-09-symmio-v0-8-4-update-contest/blob/main/protocol-core/contracts/libraries/LibSettlement.sol#L24

Solidity
File: LibSettlement.sol
15: 	function settleUpnl(
..SNIP..
30: 		require(
31: 			isForceClose || quoteLayout.partyBOpenPositions[msg.sender][partyA].length > 0,
32: 			"LibSettlement: Sender should have a position with partyA"
33: 		);

Impact

Unauthorized PartyB could settle PNL of other PartyBs and users in the system, causing disruption and breaking core protocol functionality. Unauthorized PartyB can prematurely settle PartyB's (victim) positions prematurely at times that are disadvantageous to PartyB, resulting in asset loss for them.

For example, in a highly volatile market, if PartyB’s positions temporarily incur a loss due to sudden market fluctuations, the Unauthorized PartyB could immediately settle these positions before the market has a chance to recover. This premature settlement forces PartyB to realize losses that might have otherwise been avoided if the positions had remained open.

PoC

No response

Mitigation

Include the notPartyB modifier to the settleUpnl function.

Discussion

MoonKnightDev

the check in the libSettlement.sol file prevents the scenario mentioned: https://github.com/SYMM-IO/protocol-core/blob/eac73bf1d97df96bcd5b19bcc972792ef96c70e1/contracts/libraries/LibSettlement.sol#L30

sherlock-admin2

The protocol team fixed this issue in the following PRs/commits: https://github.com/SYMM-IO/protocol-core/pull/57

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

Likely the settleUpnl function relied on a position-length check instead of the notPartyB modifier to restrict access.

Impact

An unauthorised PartyB could prematurely settle other PartyBs' positions at disadvantageous times, causing them to realise losses they might otherwise have avoided.

What the attacker needed

Removed PartyB with residual open positions

The fix

The protocol team fixed this issue by adding the notPartyB modifier to the settleUpnl function.

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 trading protocol, PartyB is a role that provides liquidity. The settleUpnl function updates the profit and loss of positions. It was supposed to be callable only by active PartyB members, but a removed PartyB could still call it if they had leftover open positions, letting them interfere with other users' trades.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

More by xiaoming90

View all

122 more disclosed reports, best first.

More from SYMMIO v0.8.4 Update Contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.