-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
First depositor can steal asset tokens of others #15
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
duplicate-243
edited-by-warden
satisfactory
satisfies C4 submission criteria; eligible for awards
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Comments
dmvt marked the issue as primary issue |
This was referenced Feb 16, 2023
Closed
[NAZ-H5] Underlying Assets Stealing In All EIP4626 Implementations via share price manipulation
#605
Closed
This was referenced Feb 16, 2023
RedVeil marked the issue as sponsor confirmed |
dmvt marked the issue as satisfactory |
dmvt marked issue #243 as primary and marked this issue as a duplicate of 243 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
duplicate-243
edited-by-warden
satisfactory
satisfies C4 submission criteria; eligible for awards
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Lines of code
https://github.com/code-423n4/2023-01-popcorn/blob/main/src/vault/Vault.sol#L134
https://github.com/code-423n4/2023-01-popcorn/blob/main/src/vault/Vault.sol#L300
Vulnerability details
Impact
ERC4626 vaults are subject to a share price manipulation attack that allows an attacker to steal underlying tokens from other depositors.
Take a look at this issue
Even though the docs says that it prevents the attack, this test is still passing.
This scenario is little bit different because first depositor can withdraw the second's assets.
Proof of Concept
Add this test to
Vault.t.sol
and run it:Tools Used
Manual, Forge
Recommended Mitigation Steps
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.
Ensure the number of shares to be minted is non-zero: require(shares != 0, "zero shares minted");
Create a periphery contract that contains a wrapper function that atomically calls initialize() and deposit()
Call deposit() once in initialize() to achieve the same effect as the suggestion above.
The text was updated successfully, but these errors were encountered: