0xAadi - Static Collateral Checks in `matchProposals()` Prevent Borrowers from Utilizing Updated/Improved Collateralization Ratios After a Partial Fulfillment #313
Static Collateral Checks in matchProposals() Prevent Borrowers from Utilizing Updated/Improved Collateralization Ratios After a Partial Fulfillment
Summary
The use of static collateralization ratio checks in matchProposals() will cause unnecessary restrictions for borrowers as the contract fails to account for the dynamic nature of the collateralization of partially fulfilled matches, potentially blocking valid matches with suitable loan offers.
Root Cause
Unlike other loan creation methods, matchProposals() has the ability to improve the collateralization ratio of a borrow request. This is due to the unique way in which matchProposals() operates.
The collateral amount required is calculated based on the loan offer, and this amount is used to update the fulfillment of the borrow request.
Since the invariant requires that the borrow request's collateralization ratio must be higher than the loan offer's collateralization ratio, the mechanism described above will positively update the collateralization ratio of the borrow request in the case of a partial match.
The vulnerability is that, even if the collateralization ratio has improved, the check still uses the amounts in the borrow request to calculate the ratio, which may be outdated.
When trying to match with another loan offer that has a 200% ratio, it will fail due to the use of outdated collateralAmount and loanAmount from the original borrow request to calculate the ratio.
Impact
Restricts Matches: Borrowers with partially fulfilled requests and higher effective collateral ratios may be unable to match with suitable loan offers.
PoC
No response
Mitigation
Dynamic Collateral Ratio Calculation: Adjust the logic to calculate the effective collateral ratio based on the remaining unfulfilled portion of the borrow request. This ensures that the check accurately reflects the borrower's current collateral position.
0xAadi
High
Static Collateral Checks in
matchProposals()
Prevent Borrowers from Utilizing Updated/Improved Collateralization Ratios After a Partial FulfillmentSummary
The use of static collateralization ratio checks in
matchProposals()
will cause unnecessary restrictions for borrowers as the contract fails to account for the dynamic nature of the collateralization of partially fulfilled matches, potentially blocking valid matches with suitable loan offers.Root Cause
Unlike other loan creation methods,
matchProposals()
has the ability to improve the collateralization ratio of a borrow request. This is due to the unique way in whichmatchProposals()
operates.The collateral amount required is calculated based on the loan offer, and this amount is used to update the fulfillment of the borrow request.
https://github.com/sherlock-audit/2024-09-predict-fun/blob/41e70f9eed3f00dd29aba4038544150f5b35dccb/predict-dot-loan/contracts/PredictDotLoan.sol#L395C1-L406C15
Since the invariant requires that the borrow request's collateralization ratio must be higher than the loan offer's collateralization ratio, the mechanism described above will positively update the collateralization ratio of the borrow request in the case of a partial match.
https://github.com/sherlock-audit/2024-09-predict-fun/blob/41e70f9eed3f00dd29aba4038544150f5b35dccb/predict-dot-loan/contracts/PredictDotLoan.sol#L351C9-L357C1
The vulnerability is that, even if the collateralization ratio has improved, the check still uses the amounts in the borrow request to calculate the ratio, which may be outdated.
Internal pre-conditions
No response
External pre-conditions
Example proposals
Proposal borrowRequest
Proposal loanOffer
Attack Path
For the borrow request:
Here we can see that the borrow request has been fulfilled with a
collateralAmount
of500 ether
and aloanAmount
of500 ether
.This means the remaining borrow request still needs to fulfill a
collateralAmount
of1000 ether
and aloanAmount
of500 ether
.So the calculation for the remaining portion will be:
Impact
Restricts Matches: Borrowers with partially fulfilled requests and higher effective collateral ratios may be unable to match with suitable loan offers.
PoC
No response
Mitigation
Dynamic Collateral Ratio Calculation: Adjust the logic to calculate the effective collateral ratio based on the remaining unfulfilled portion of the borrow request. This ensures that the check accurately reflects the borrower's current collateral position.