First depositor can break miting of shares #272
Labels
bug
Something isn't working
downgraded by judge
Judge downgraded the risk level of this issue
duplicate-848
edited-by-warden
grade-b
QA (Quality Assurance)
Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax
satisfactory
satisfies C4 submission criteria; eligible for awards
Lines of code
https://github.com/code-423n4/2023-02-ethos/blob/main/Ethos-Vault/contracts/ReaperVaultV2.sol#L334
Vulnerability details
Impact
The attack vector and impact is the same as TOB-YEARN-003 , where users may not receive shares in exchange for their deposits if the total asset amount has been manipulated through a large “donation”.
This issue in deposit function, the amount of the minted shares can round down to zero.
Proof of Concept
A malicious early user / first depositor of the Vault can deposit with
1 wei
of theasset token
and then get1 wei
of shares token.Then the malicious attacker can send
10000e18
amount ofasset
tokens and inflate the price from1.000
to the extreme value of1.0000e22
As a result, the next users who deposit
199999e18
wei will only receive 1 wei of shares inshares = (_amount * totalSupply()) / freeFunds
.So, the legitimate user will lose
9999e18
after their deposit.This is a common risk of Empty ERC4626 Vaults, due to rounding in favor of the vault. The attack can also be performed as a frontrunning attack.
https://github.com/code-423n4/2023-02-ethos/blob/main/Ethos-Vault/contracts/ReaperVaultV2.sol#L334
Tools Used
Manual
Recommended Mitigation Steps
In Uniswap V2 solved this problem by sending the first 1000 LP tokens to the zero address. The same can be done in this case i.e. when totalSupply() == 0, send the first min liquidity LP tokens to the zero address to enable share dilution.
Also, it is advised to monitor the Openzeppelin Discussion and Solmate Discussion for possible mitigation to the issue.
The text was updated successfully, but these errors were encountered: