Normal behavior: The updateExchangeRate function calculates a new exchange rate based on collected fees and total token supply. This mechanism ensures asset token holders receive their proportional share of protocol fees through appreciation of their tokens.
The issue: The function divides by totalSupply() without checking if it's zero. When totalSupply() = 0, the division operation s_exchangeRate * (totalSupply() + fee) / totalSupply() will revert due to division by zero, permanently disabling the fee mechanism.
https://github.com/CodeHawks-Contests/ai-thunder-loan/blob/ef8516ae0c0b683dab7928eab1490ac2d9b09209/src/protocol/AssetToken.sol#L89
The vulnerable code is in the updateExchangeRate function:
function updateExchangeRate(uint256 fee) external onlyThunderLoan {
uint256 newExchangeRate = s_exchangeRate * (totalSupply() + fee) / totalSupply();
Likelihood:
This occurs when all asset tokens have been burned/redeemed, bringing total supply to zero
While uncommon in active protocols, it can happen during protocol shutdown, migration, or if an attacker deliberately manipulates supply
Requires coordinated action by all token holders or specific protocol conditions
Impact:
Permanent disablement of the updateExchangeRate function - core protocol functionality breaks
Protocol fees cannot be distributed, disrupting economic incentives
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.