In ThunderLoan.sol, the deposit function violates this pattern. It updates the exchange rate, calculates the mint amount, and mints AssetTokens to the user before executing the safeTransferFrom call to pull the underlying tokens into the vault. This creates a state mismatch where internal share accounting is modified prior to actual token custody transfer.
Likelihood:
Attackers interact directly with the deposit entry point using custom tokens or leverage multi-step transaction vectors.
State variables and share calculations process prior to the completion of external ERC20 transfers.
Impact:
Protocol internal state inconsistency regarding total assets versus total minted shares.
Vulnerability to balance/exchange-rate manipulation vectors during deposit execution phases.
Explanation: To verify this vulnerability, an auditor can inspect the order of operations in deposit(). Because assetToken.mint() is called before token.safeTransferFrom(), any callback or re-entrant hook triggered by a non-standard ERC20 token (or a malicious receiver) will observe an updated token balance state and minted shares before the underlying assets have legally arrived in the assetToken contract.
Explanation: To resolve this issue, strictly follow the Checks-Effects-Interactions pattern. Pull the underlying tokens into the protocol via safeTransferFrom first, ensuring the contract actually holds the funds, and only then perform internal accounting updates, share minting, and exchange rate modifications.
The contest is live. Earn rewards by submitting a finding.
Submissions are being reviewed by our AI judge. Results will be available in a few minutes.
View all submissionsThe contest is complete and the rewards are being distributed.