vatsal - rounding error due to internal accounting and can steal some portion of the first depositors funds #597
Labels
Has Duplicates
A valid issue with 1+ other issues describing the same vulnerability
High
A High severity issue.
Reward
A payout will be made for this issue
Sponsor Confirmed
The sponsor acknowledged this issue is valid
Will Fix
The sponsor confirmed this issue will be fixed
vatsal
High
rounding error due to internal accounting and can steal some portion of the first depositors funds
Summary
Vulnerability Detail
where: All basepool
when: Total Supply of a pool is zero
When total supply of pool is zero an attacker goes ahead and executes the following steps
In a loop attacker does the following till they get their desired price of 1 share
convertToShares = assets.mulDiv(totalShares, totalAssets, rounding);
shares = (amount * total.shares) / total.amount
of shares.totalDepositShares = 1+1 (minted shares )- 1 (withdrew amount )= 1
andtotalDeposits = totalDeposits + totalDeposits + 1
So when a user comes to the deposit get some shares but they lose of assets which get proportionally divided between existing share holders (including the attacker) due to rounding errors.
Impact
Code Snippet
Recommendation
I like how BalancerV2 and UniswapV2 do it
The text was updated successfully, but these errors were encountered: