The vulnerability stems from the Lender.sol
contract's assumption that all ERC20 tokens behave uniformly when transferred. Yet, fee-on-transfer tokens, with transfer taxes, deviate from this behavior, causing discrepancies between sent and received amounts. Using these tokens in the protocol triggers issues, leading to overestimation of a user's debt during borrowing. This discrepancy obstructs loan repayment and collateral retrieval.
The vulnerability arises from the flawed assumption within the Lender.sol
contract that all ERC20 tokens adhere uniformly to transfers. However, tokens with fee-on-transfer mechanisms, such as those involving transfer taxes, exhibit distinct behavior. The tokens' sender-sent amount doesn't match the destination-received amount, leading to discrepancies.
The issue is exacerbated when employing transfer-on-fee tokens within the protocol. This scenario distorts the user's debt calculation during loan acquisition. Consequently, borrowers may struggle to repay loans and retrieve their collateral accurately.
This vulnerability significantly skews debt calculations in the protocol. Consequently, borrowers face challenges repaying loans and regaining collateral. Consider a hypothetical instance: a pool accommodating USDT collateral with a 1% transfer tax. Borrowing $500 ETH requires sending $1,000 USDT. Though Alice forwards $1,000, transaction fees reduce this to $990, received by the protocol. Subsequently, when Alice repays the $500 ETH via the repay()
function, it tries to transfer $1,000 USDT. However, since Alice's collateral doesn't cover this amount, the transaction may fail (note: this failure might not be detected due to unchecked transfer and transferFrom
return values).
Manual Review
To rectify this, when calculating collateral received by the protocol, ascertain the balance of the Lender before and after receiving the collateral. Employ the difference between these balances to determine the accurate collateral amount.
As an illustration, adjust the borrow() function as demonstrated below:
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.