The vulnerability resides in the incorrect calculation of the flash loan fee within the ThunderLoan smart contract. Specifically, the fee is mistakenly being taken from the user's total balance rather than being calculated based on the flash loaned amount.
The relevant code snippet from the ThunderLoan contract is as follows:
The fee calculation should use the amount that is being flash loaned (amount), but due to the design of the getCalculatedFee function, it ends up using the total token value in relation to ETH price, causing the fee to be disproportionately high and incorrect.
The impact of this vulnerability is two-fold:
User Impact: Users who take out flash loans are overcharged, leading to an unjustified depletion of their funds. This can result in significant financial losses for users and can deter them from using the platform.
Reputational Damage: The discovery of such a flaw can lead to a loss of trust in the ThunderLoan platform, affecting its reputation and potentially causing a decline in user base and volume.
The getCalculatedFee function should be modified to calculate the fee based on the flash loaned amount only.
Here is a proposed fix for the getCalculatedFee function:
This revised function ensures that the fee is calculated as a percentage of the actual amount being flash loaned, rather than the user's total balance or the token's value in ETH.
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.