In ThunderLoan.sol:85
, there is a reentrancy vulnerability due to the ordering of operations in the deposit
function. The function performs an ERC20 token transfer to deposit funds after minting new asset tokens, which should be the other way around to prevent reentrancy attacks.
Vulnerable code:
Reentrancy can allow an attacker to repeatedly call the deposit
function, enabling them to withdraw more funds than they deposited before the original transaction is completed. This could result in the depletion of the contract's funds and potentially render the contract insolvent.
Manual Review
Vs Code
Update State Before Transfers: The contract should change its state (mint
function call in this context) after performing the safeTransferFrom
function to ensure funds are received before any new asset tokens are minted.
Reentrancy Guard: Introduce a reentrancy guard by using a mutex or the Checks-Effects-Interactions pattern. This pattern recommends that you should make all state changes before calling external contracts.
Possible fix:
Transfer the tokens before minting any new 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.