This repository has been archived by the owner on Mar 3, 2024. It is now read-only.
lil.eth - First depositor on LMPVault.sol can break minting of shares #112
Labels
Excluded
Excluded by the judge without consulting the protocol or the senior
Non-Reward
This issue will not receive a payout
lil.eth
high
First depositor on LMPVault.sol can break minting of shares
Summary
The common "first depositor" vulnerability is found in
LMPVault#deposit()
. The first account to deposit into the LMPVault can steal value from subsequent depositors by:Math.rounding.down
specification)Vulnerability Detail
The depositor's shares are calculated via:
Upon first deposit, the
totalAssets()
value will be 0. The attacker will transact with anamount = 1 wei
to mint 1 wei of shares. Then the attacker will transfer some value of asset directly to the contract. For this example, the attacker transfers 10,000 USDC.Next, a subsequent depositor attempts to mint shares with 5,000 USDC.
shares = 5000 USDC * 1 wei / 10,000 USDC = 0
due to precision loss.The attacker can now withdraw the second depositor's assets.
Other vulnerabilities related to this one can be found here : OpenZeppelin/openzeppelin-contracts#3706
Impact
Theft of deposit
Code Snippet
https://github.com/sherlock-audit/2023-06-tokemak/blob/main/v2-core-audit-2023-07-14/src/vault/LMPVault.sol#L332
Tool used
Manual Review
Recommendation
Mint a certain number of shares and transfer them to
address(0)
within theinitialize()
function.Refer to this article for better understanding/remediation
The text was updated successfully, but these errors were encountered: