ERC777 reentrancy risk due to missing nonReentrant modifier and not following CEI pattern
ERC777 tokens allow arbitrary callbacks via hooks that are called during token transfers. Malicious contracts can utilize these hooks and perform a reentrancy.
This vulnerability exists because seizeLoan doesn't adhere to the CEI pattern, we delete the loan here, while we transfer the tokens here. Also seizeLoan doesn't implement any reentrancy guard to guard against this sort of attacks.
Let's imagine the following scenario:
A lender's loan auction has ended and now his loan can be seized.
Someone calls seizeLoan to seize the loan.
Once we hit this line the transfer of tokens begins.
If the token is an ERC777 token it will execute a callback and inside that callback a malicious contract can call seizeLoan again effectively doubling the amount of collateral the lender will receive accordingly.
The almost exact same issue can be seen in the repay function.
Loss of funds for the protocol.
Manual review
Implement OpenZeppelin's ReentrancyGuard and add the nonReentrant modifier to seizeLoan.
Move the line delete loans[loanId] before the transferring of tokens.
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.