Thunder Loan

AI First Flight #7
Beginner FriendlyFoundryDeFiOracle
EXP
View results
Submission Details
Severity: low
Valid

Small flash loans round the fee down to zero

Summary

For sufficiently small loan values, integer division in getCalculatedFee returns a zero fee. Because flashloan does not require a positive fee, borrowers can execute unlimited small loans for free.

Root cause and evidence

ThunderLoan.sol:246-250 performs integer arithmetic and rounds down. With s_flashLoanFee = 3e15, any normalized borrowed value below the threshold needed to produce one smallest token unit yields fee == 0. flashloan at lines 180-216 accepts that result and only requires repayment of principal.

Impact

The protocol provides free liquidity for small amounts and earns no yield on those operations. Attackers can repeat them or combine them with operations where small no-fee loans are economically useful.

Minimal patch

Define a minimum fee (for example one smallest unit when amount > 0) or round fee calculation up with a documented policy. Consider a minimum borrow amount for assets where one unit is too coarse.

Regression test

Test the smallest positive borrow values and assert every nonzero successful loan charges at least the configured minimum fee while ordinary-size fees remain correct.

Updates

Lead Judging Commences

ai-first-flight-judge Lead Judge about 2 hours ago
Submission Judgement Published
Validated
Assigned finding tags:

[L-01] getCalculatedFee can be 0

## 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.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!