Invalid CR validation in Size::compensate
, blocking users from compensating their loans
#434
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
duplicate-107
edited-by-warden
🤖_188_group
AI based duplicate group recommendation
satisfactory
satisfies C4 submission criteria; eligible for awards
sufficient quality report
This report is of sufficient quality
Lines of code
https://github.com/code-423n4/2024-06-size/blob/main/src/Size.sol#L250
Vulnerability details
Impact
Users can use their credit to compensate for some of their debt, this is done by calling
Size::compensate
. Compensate sometimes contains collateral transfers, however, it only happens if fragmentation happens on a credit position. But the protocol is checking if the user is liquidatable on every compensate TX, even if it doesn't include collateral transfers.If a liquidatable borrower (has >1 loan), tries to compensate a loan with an exact credit position he owns, but he's unable to compensate 1 loan because he's still liquidatable with the remaining loan, this is because it's checking the user's CR, knowing that no fragmentation happened.
So a user won't be able to compensate his loan because of an invalid CR check, where it shouldn't be triggered as no fragmentation happened.
Proof of Concept
The below test how the borrower is blocked from compensating his loan. To confirm that this works as expected, temporarily remove
state.validateUserIsNotUnderwater(msg.sender);
fromSize::compensate
, and verify that the below test doesn't revert.Tools Used
Manual review
Recommended Mitigation Steps
Instead of checking if the user is underwater on every compensate action, only check it if some credit fragmentation happens. In other words, don't check for the user's CR if no collateral tokens were moved.
Assessed type
Invalid Validation
The text was updated successfully, but these errors were encountered: