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

In _depositOnVaultCreation, assets are not coverted into shares #75

Open
hats-bug-reporter bot opened this issue Jun 30, 2024 · 1 comment
Open
Labels
bug Something isn't working duplicate This issue or pull request already exists

Comments

@hats-bug-reporter
Copy link

Github username: --
Twitter username: --
Submission hash (on-chain): 0x6136a377e37728893b5ff6432b34d5f304b13b9baf6c039465823a705d33e801
Severity: high

Description:
Description
Upon creation of an Atom, a user can be the first depositor in the Atom they've created using _depositOnVaultCreation. They send msg.value that should be their deposited amount.

The problem is the assets amount is used as shares and the user will get much more shares than he should.

        uint256 sharesForReceiver = assets;
        _mint(receiver, id, sharesForReceiver);

As we can see in the _deposit, getDepositSharesAndFees is called to calculate the shares for the provided amount.

        (uint256 totalAssetsDelta, uint256 sharesForReceiver, uint256 userAssetsAfterTotalFees, uint256 entryFee) =
            getDepositSharesAndFees(value, id);

Attack Scenario
Let's assume 5 assets = 1 share;

User deposits 5 assets, 5 shares will be minted to him. Later when he redeem, he will have 5 shares which will be equal to 25 assets.

Making the user get 20 more assets with only 5 deposited.

Describe how the vulnerability can be exploited.

Attachments

  1. Proof of Concept (PoC) File
  1. Revised Code File (Optional)
+        (uint256 totalAssetsDelta, uint256 sharesForReceiver, uint256 userAssetsAfterTotalFees, uint256 entryFee) = getDepositSharesAndFees(assets, id);
+        uint256 sharesForReceiver = sharesForReceiver;

-        uint256 sharesForReceiver = assets;

@hats-bug-reporter hats-bug-reporter bot added the bug Something isn't working label Jun 30, 2024
@mihailo-maksa mihailo-maksa added the duplicate This issue or pull request already exists label Jul 1, 2024
@mihailo-maksa
Copy link
Collaborator

Duplicate of issue #74.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

1 participant