The borrow function in the LendingPool contract has a vulnerability in its collateral validation logic that allows users to borrow more than their collateral should permit. The issue stems from an incorrect order of operations in the percentMul calculation.
The vulnerability exists in the borrow function's collateral validation check:
When a user with 100 ETH collateral attempts to borrow 120 ETH:
userTotalDebt = 120 ETH
liquidationThreshold = 80% (8000 basis points)
userTotalDebt.percentMul(liquidationThreshold) = 96 ETH
100 ETH collateral > 96 ETH required -> Check passes incorrectly
Proof of Concept: Add this test to LendingPool.test.js to reproduce the issue.
Users can borrow more than their collateral should allow, putting the protocol at risk of undercollateralized loans. In the example above, a user with 100 ETH collateral can borrow 120 ETH when they should only be able to borrow 80 ETH
Manual code review
Hardhat test suite
Modify the collateral validation check in the borrow function to:
This ensures the collateral value is scaled by the liquidation threshold before comparing to the debt amount.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.