First Deposit Can be frontrun to make amount minted round down to zero #85
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
duplicate-42
edited-by-warden
satisfactory
satisfies C4 submission criteria; eligible for awards
sufficient quality report
This report is of sufficient quality
Lines of code
https://github.com/code-423n4/2023-11-kelp/blob/c5fdc2e62c5e1d78769f44d6e34a6fb9e40c00f0/src/LRTDepositPool.sol#L95-L110
Vulnerability details
Impact
First Deposit Can be frontrun to make amount minted round down to zero, which means the attacker gets 100% of the victims deposit contributed to the rsEth exchange rate.
Proof of Concept
When
deposit
is called when there are already pre-existing deposits, the conversion rate istotalETHInPool / rsEthSupply
When an intial deposit is sent to the pool, this can be front run by:
totalETHInPool
such thattotalETHInPool / rsEthSupply
is greater thanamount * lrtOracle.getAssetPrice(asset)
of the victim's deposittotalETHInPool / rsEthSupply
is greater thanamount * lrtOracle.getAssetPrice(asset)
Therefore zero shares are minted for the victim, and will result in a greater share of the pool for the attacker, since they still have 100% rsEth, and a boosted conversion rate, which still applies for future deposits. When withdrawals are implemented, this also means they can withdraw the entire victims deposit and whatever assets they sent directly to the contract.
Tools Used
Manual Review
Recommended Mitigation Steps
Use internal accounting which tracks deposits and withdrawals rather than
balanceOf
Assessed type
Math
The text was updated successfully, but these errors were encountered: