-
Notifications
You must be signed in to change notification settings - Fork 4
xiaoming90 - Liquidation can be blocked by incrementing the nonce #233
Comments
Escalate
And it's not like a locked offer where partA has to wait for a cool period of to cancel lock. The liquidator can send the liquidation request again immediately after partA maliciously adds the nonce, and it is nearly impossible to prevent the liquidation continuously. |
You've created a valid escalation! 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. |
Then the party A can increment nonce again:
Recommend maintaining high severity |
This is why DOS is invalid, anyone can send a transaction again, unless DOS can be in effect for a year, otherwise it should be considered invalid due to the huge cost. |
By increasing nonce, PartyA is actually buying himself the time to get account back to health level (front-run to deposit more funds), then he won't be liquidated by anyone and that's how liquidator is DOSed. |
I don't think the duration of DOS can affect the liquidation:
|
Malicious user can DOS the liquidation by frontrun until he can make a profit. |
Result: |
Escalations have been resolved successfully! Escalation status:
|
Fixed code PR link: |
xiaoming90
high
Liquidation can be blocked by incrementing the nonce
Summary
Malicious users could block liquidators from liquidating their accounts, which creates unfairness in the system and lead to a loss of profits to the counterparty.
Vulnerability Detail
Instance 1 - Blocking liquidation of PartyA
A liquidatable PartyA can block liquidators from liquidating its account.
https://github.com/sherlock-audit/2023-06-symmetrical/blob/main/symmio-core/contracts/facets/liquidation/LiquidationFacetImpl.sol#L20
Within the
liquidatePartyA
function, it calls theLibMuon.verifyPartyAUpnl
function.https://github.com/sherlock-audit/2023-06-symmetrical/blob/main/symmio-core/contracts/libraries/LibMuon.sol#L87
The
verifyPartyAUpnl
function will take the current nonce of PartyA (AccountStorage.layout().partyANonces[partyA]
) to build the hash needed for verification.When the PartyA becomes liquidatable or near to becoming liquidatable, it could start to monitor the mempool for any transaction that attempts to liquidate their accounts. Whenever a liquidator submits a
liquidatePartyA
transaction to liquidate their accounts, they could front-run it and submit a transaction to increment their nonce. When the liquidator's transaction is executed, the on-chain PartyA's nonce will differ from the nonce in the signature, and the liquidation transaction will revert.For those chains that do not have a public mempool, they can possibly choose to submit a transaction that increments their nonce in every block as long as it is economically feasible to obtain the same result.
Gas fees that PartyA spent might be cheap compared to the number of assets they will lose if their account is liquidated. Additionally, gas fees are cheap on L2 or side-chain (The protocol intended to support Arbitrum One, Arbitrum Nova, Fantom, Optimism, BNB chain, Polygon, Avalanche as per the contest details).
There are a number of methods for PartyA to increment their nonce, this includes but not limited to the following:
requestToClosePosition
followed byrequestToCancelCloseRequest
immediatelyInstance 2 - Blocking liquidation of PartyB
The same exploit can be used to block the liquidation of PartyB since the
liquidatePartyB
function also relies on theLibMuon.verifyPartyBUpnl,
which uses the on-chain nonce of PartyB for signature verification.https://github.com/sherlock-audit/2023-06-symmetrical/blob/main/symmio-core/contracts/facets/liquidation/LiquidationFacetImpl.sol#L240
Impact
PartyA can block their accounts from being liquidated by liquidators. With the ability to liquidate the insolvent PartyA, the unrealized profits of all PartyBs cannot be realized, and thus they will not be able to withdraw the profits.
PartyA could also exploit this issue to block their account from being liquidated to:
Since this is a zero-sum game, the above-mentioned create unfairness to PartyB and reduce their profits.
The impact is the same for the blocking of PartyB liquidation.
Code Snippet
https://github.com/sherlock-audit/2023-06-symmetrical/blob/main/symmio-core/contracts/facets/liquidation/LiquidationFacetImpl.sol#L20
https://github.com/sherlock-audit/2023-06-symmetrical/blob/main/symmio-core/contracts/facets/liquidation/LiquidationFacetImpl.sol#L240
Tool used
Manual Review
Recommendation
In most protocols, whether an account is liquidatable is determined on-chain, and this issue will not surface. However, the architecture of Symmetrical protocol relies on off-chain and on-chain components to determine if an account is liquidatable, which can introduce a number of race conditions such as the one mentioned in this report.
Consider reviewing the impact of malicious users attempting to increment the nonce in order to block certain actions in the protocols since most functions rely on the fact that the on-chain nonce must be in sync with the signature's nonce and update the architecture/contracts of the protocol accordingly.
The text was updated successfully, but these errors were encountered: