-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
hash - User's can seize more assets during liquidation by using type(uint).max #556
Comments
LIQUIDATION_DISCOUNT
and always seize all collateral
#443
I cannot escalate the issue due to an insufficient escalation threshold. Hi @z3s, Why was this issue downgraded to medium? With this vulnerability, a liquidator can seize all collateral. For proof, please refer to the coded PoC in my issue (#505). For this reason, this issue should be high. Thanks for your time. |
Escalate, |
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. |
@z3s Can you give your opinion, please? |
I'm unclear why the lead judge classified this issue as Medium, but I believe this issue can be High severity. The core problem lies in the ability to replay a previous repayment using This manipulation results in liquidators seizing significantly more collateral than they are entitled to. Such a flaw could lead to borrowers losing a much larger portion of their collateral, creating a direct financial loss for affected users. Planning to accept the escalation and make this issue High severity. |
Result: |
Escalations have been resolved successfully! Escalation status:
|
The protocol team fixed this issue in the following PRs/commits: |
hash
High
User's can seize more assets during liquidation by using type(uint).max
Summary
User's can seize more assets during liquidation than what should be actually allowed by replaying the repayment amount using type(uint).max
Vulnerability Detail
The liquidators are restricted on the amount of collateral they can seize during a liquidation
Eg:
if a position has 1e18 worth debt, and 2e18 worth collateral, then on a liquidation the user cannot seize 2e18 collateral by repaying the 1e18 debt, and they are limited to seizing for ex. 1.3e18 worth of collateral (depends on the liquidation discount how much profit a liquidator is able to generate)
The check for this max seizable amount is kept inside
_validateSeizedAssetValue
link
But the
_validateSeizedAssetValue
is flawed as it assumes that the valuetype(uint256).max
will result in the liquidator repaying the currentpool.getBorrowsOf(poolId, position)
value. In the actual execution, an attacker can repay some amount earlier and then usetype(uint256).max
on the same pool which will result in a decreased amount because debt has been repaid earlierEg:
getBorrows of position = 1e18
user passes in 0.9e18 and type(uint).max as the repaying values
the above snippet will consider it as 0.9e18 + 1e18 being repaid and hence allow for more than 1.9e18 worth of collateral to be seized
but during the actual execution, since 0.9e18 has already been repaid, only 0.1e18 will be transferred from the user allowing the user
POC Code
Apply the following diff and run
testHash_LiquidateExcessUsingDouble
. It is asserted that a user can use this method to seize the entire collateral of the debt position even though it results in a much higher value than what should be actually allowedImpact
Borrowers will loose excess collateral during liquidation
Code Snippet
https://github.com/sherlock-audit/2024-08-sentiment-v2/blob/25a0c8aeaddec273c5318540059165696591ecfb/protocol-v2/src/RiskModule.sol#L129-L145
Tool used
Manual Review
Recommendation
Only allow a one entry for each poolId in the
debtData
array. This can be enforced by checking that the array is in a strictly sequential order on poolsThe text was updated successfully, but these errors were encountered: