The flash loan fee is calculated as:
Due to integer division truncation, borrowing sufficiently small amounts (e.g., valueOfBorrowedToken = 3e2) results in a calculated fee of zero.
This allows borrowers to repeatedly take flash loans without paying any fee. If s_flashLoanFee is reduced in the future, the exploitable borrowing threshold increases, further worsening the issue.
Likelihood:
This bug is likely to happen because a very little benefit to the attacker. While the attacker will not pay the fee, but the amount borrowed is so little, from the calculation, the attacker can borrow at maximal 3e2 per one transaction.
If this run on ethereum chain and the ethereum chain on heavy traffic, the gas fee might be higher than the benefit of looping this transaction to avoid the fee.
Impact:
The impact is quite significant if the attacker run this attack multiple times. Protocol will not get any of the fees.
## Description getCalculatedFee can be as low as 0 ## Vulnerability Details Any value up to 333 for "amount" can result in 0 fee based on calculation ``` function testFuzzGetCalculatedFee() public { AssetToken asset = thunderLoan.getAssetFromToken(tokenA); uint256 calculatedFee = thunderLoan.getCalculatedFee( tokenA, 333 ); assertEq(calculatedFee ,0); console.log(calculatedFee); } ``` ## Impact Low as this amount is really small ## Recommendations A minimum fee can be used to offset the calculation, though it is not that important.
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.