Lender.sol - Reentrancy Vulnerability when using ERC777 loan tokens
Since the protocol is expected to support all ERC20-compatible tokens, ERC777 tokens (backward compatible with of ERC20) should be supported too. In Lender.sol, the contract does not follow the CEI pattern correctly, updating pools storage after the token transfer. This makes the contract vulnerable to reentrancy attacks if the malicious pool lender implements tokensReceived hook.
A malicious actor can exploit the reentrancy vulnerability to manipulate the currentBalance - p.poolBalance amount, potentially draining all loanToken in this contract.
Manual Review
To address this vulnerability, ensure that the contract follows the correct Checks-Effects-Interractions pattern, updating pools state before the token transfer.
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.