flashloan() Allows Borrowers to Bypass Repayment ValidationThe flashloan() function is vulnerable to reentrancy because it performs an external call to an attacker-controlled contract before validating that the flash loan has been repaid.
An attacker can reenter flashloan() from within executeOperation() and manipulate the repayment accounting logic so that only the nested flash loan repayment is validated, while the initial flash loan remains unpaid.
This can result in direct loss of funds from the protocol.
The vulnerability originates from the following external call:
Before this external interaction, the protocol transfers the borrowed funds to the receiver:
Because receiverAddress is fully attacker-controlled, the attacker can reenter flashloan() during the execution of executeOperation().
The issue is that repayment validation only occurs after the external call returns:
During reentrancy, a second flash loan invocation creates a new startingBalance snapshot and performs its own repayment validation independently.
This allows the attacker to repay only the nested flash loan while leaving the original borrowed amount unpaid.
Since the outer call relies on balance-based accounting after control flow has already been manipulated, the repayment check can incorrectly succeed.
An attacker can exploit this vulnerability to steal funds from the protocol by bypassing repayment requirements for the initial flash loan.
Because flash loans can access the full available liquidity of the pool, this issue can lead to significant or total loss of funds.
Attacker calls flashloan()
Protocol transfers funds to attacker contract
Protocol calls executeOperation()
Inside executeOperation(), attacker reenters flashloan()
Nested flash loan completes successfully
Attacker repays only the nested flash loan
Original flash loan repayment validation is bypassed
Add a nonReentrant modifier to the flashloan() function.
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.