IdleYieldSource doesn’t use mantissa calculations
The IdleYieldSource contract does not use mantissa calculations to account for decimals, so integer division can round down to zero. An attacker could deposit a small amount and receive zero shares, losing their deposit.
Submitted by tensors
Because mantissa calculations are not used in this case to account for decimals, the arithmetic can zero out the number of shares or tokens that should be given.
For example, say I deposit 1 token, expecting 1 share in return. On L95, if the totalUnderlyingAssets is increased to be larger than the number of total shares, then the division would output 0 and I wouldn’t get any shares.
Recommend implementing mantissa calculations like in the contract for the AAVE yield.
PierrickGT (PoolTogether) confirmed and patched:
PR: https://github.com/pooltogether/idle-yield-source/pull/5
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Impact
A user could lose their deposit by receiving zero shares when the division rounds down.
What the attacker needed
TotalUnderlyingAssets > totalShares; user deposits a small amount
The fix
The issue was fixed by implementing mantissa calculations as in the AAVE yield contract.
How it was found
- Deposit 1 token expecting 1 share in return.
- If totalUnderlyingAssets is larger than total shares, the division outputs 0.
- The depositor receives no shares.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Smart contracts often use whole numbers, so when dividing, any fraction is thrown away. If the result is less than one, it becomes zero. Here, a user depositing a small amount could get zero shares because the division rounded down.