This repository has been archived by the owner on Mar 10, 2024. It is now read-only.
xiaoming90 - Ineffective liquidation signatures expiration mechanism #35
Labels
Disagree With (non-)Duplication
The sponsor disputed the duplication state of this issue
Duplicate
A valid issue that is a duplicate of an issue with `Has Duplicates` label
High
A valid High severity issue
Reward
A payout will be made for this issue
Sponsor Confirmed
The sponsor acknowledged this issue is valid
Will Fix
The sponsor confirmed this issue will be fixed
xiaoming90
high
Ineffective liquidation signatures expiration mechanism
Summary
The new PartyA's liquidation process relies on the timestamp to expire old liquidation signatures, which is ineffective.
Vulnerability Detail
Assume that
MuonStorage.layout().upnlValidTime
is set to 15 minutes. In this case, theliquidatePartyA
function accepts the liquidation signature generated up to 15 minutes ago.https://github.com/sherlock-audit/2023-08-symmetrical/blob/main/symmio-core/contracts/facets/liquidation/LiquidationFacetImpl.sol#L20
Assume that Alice account is liquidatable.$Liquidator_A$ and $Liquidator_B$ generate a liquidation signature within the time period highlighted in green below. Subsequently, at T0, $Liquidator_A$ calls the
liquidatePartyA
function to initiate the liquidation process and "lock-in" its liquidation ID.For simplicity's sake, the liquidation process is executed atomically within the same block. As such, the liquidation process is completed at T0.
The issue is that if Alice started trading again within T0 and T1, she could be liquidated again by$Liquidator_A$ or $Liquidator_B$ using back the old liquidation signature even if her account is healthy.
Impact
Liquidating a healthy account would result in a loss of assets for the victim.
Code Snippet
https://github.com/sherlock-audit/2023-08-symmetrical/blob/main/symmio-core/contracts/facets/liquidation/LiquidationFacetImpl.sol#L20
Tool used
Manual Review
Recommendation
The root cause is that the new design relies only on the timestamp to expire old liquidation signatures, which is insufficient to protect against replay attacks.
To adequately guard against this attack, all liquidation signatures generated at or before T0 should be automatically marked as invalid after the liquidation process is completed at T0. In this case, it is no longer possible for$Liquidator_A$ and $Liquidator_B$ using back the old liquidation signature, which was generated at or before T0.
One possible solution is to save the timestamp of the last liquidation completed (
lastLiquidationCompleted
). In our example, once the liquidation process is completed at T0, T0 will be saved tolastLiquidationCompleted
state. When the liquidator calls theliquidatePartyA
function to initiate the liquidation process, the function can check if the liquidation signature provided is newer thanlastLiquidationCompleted
, effectively preventing anyone from using the old liquidation signatures from the last liquidation event.Duplicate of #5
The text was updated successfully, but these errors were encountered: