Skip to content
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

A malicious early user can deposit() with 1 wei of asset token as the first depositor of the vault contract, and get 1 wei of shares. #55

Closed
code423n4 opened this issue Feb 2, 2023 · 4 comments
Labels
3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working edited-by-warden sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity") unsatisfactory does not satisfy C4 submission criteria; not eligible for awards

Comments

@code423n4
Copy link
Contributor

code423n4 commented Feb 2, 2023

Lines of code

https://github.com/code-423n4/2023-01-popcorn/blob/d95fc31449c260901811196d617366d6352258cd/src/vault/Vault.sol#L294

Vulnerability details

Impact

A malicious early user can deposit() with 1 wei of asset token as the first depositor of the LToken, and get 1 wei of shares.
Then the attacker can send 10000e18 - 1 of asset tokens and inflate the price per share from 1.0000 to an extreme value of 1.0000e22 ( from (1 + 10000e18 - 1) / 1).
As a result, the future user who deposits 19999e18 will only receive 1 wei (from 19999e18 * 1 / 10000e18) of shares token.
They will immediately lose 9999e18 or half of their deposits if they redeem() right after the deposit().

Proof of Concept

https://github.com/code-423n4/2023-01-popcorn/blob/d95fc31449c260901811196d617366d6352258cd/src/vault/Vault.sol#L294

https://github.com/sherlock-audit/2022-08-sentiment-judging/blob/main/004-H/004-h.md
transmissions11/solmate#178

Tools Used

manually

Recommended Mitigation Steps

Consider requiring a minimal amount of share tokens to be minted for the first minter, and send a port of the initial mints as a reserve to the DAO.

@code423n4 code423n4 added 3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working labels Feb 2, 2023
code423n4 added a commit that referenced this issue Feb 2, 2023
@code423n4 code423n4 changed the title BAD Users Can Drain The Assets Of Vault A malicious early user can deposit() with 1 wei of asset token as the first depositor of the LToken, and get 1 wei of shares. Feb 5, 2023
@code423n4 code423n4 changed the title A malicious early user can deposit() with 1 wei of asset token as the first depositor of the LToken, and get 1 wei of shares. A malicious early user can deposit() with 1 wei of asset token as the first depositor of the vault contract, and get 1 wei of shares. Feb 5, 2023
@c4-judge
Copy link
Contributor

dmvt marked the issue as duplicate of #15

@c4-sponsor
Copy link

RedVeil marked the issue as sponsor confirmed

@c4-sponsor c4-sponsor added the sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity") label Feb 18, 2023
@c4-judge c4-judge reopened this Mar 1, 2023
@c4-judge
Copy link
Contributor

c4-judge commented Mar 1, 2023

dmvt marked the issue as not a duplicate

@c4-judge
Copy link
Contributor

c4-judge commented Mar 1, 2023

dmvt marked the issue as unsatisfactory:
Invalid

@c4-judge c4-judge closed this as completed Mar 1, 2023
@c4-judge c4-judge added the unsatisfactory does not satisfy C4 submission criteria; not eligible for awards label Mar 1, 2023
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 edited-by-warden sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity") unsatisfactory does not satisfy C4 submission criteria; not eligible for awards
Projects
None yet
Development

No branches or pull requests

3 participants