Vault is vulnerable to inflation attack which can cause complete loss of user funds
The vault contract calculates the exchange rate using the contract's token balance, which can be inflated by direct donation. An attacker can become the first depositor with a tiny amount, donate a large sum to inflate the share price, causing the next depositor to receive zero shares, and then redeem their single share to steal all funds.
0xlucky Follow with Abhan1041, AestheticBhai and 8 others
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2024-12-numa-audit-judging/issues/253
Found by
0xlucky, Abhan1041, AestheticBhai, KupiaSec, Oblivionis, ZZhelev, blutorque, jokr, juaan, novaman33, smbv-1923
Summary
Attacker can attack the first depositors in the vault and can steal all users funds. this attack is also famously known has first deposit bug too. while doing this attack , there is no loss of attacker funds, but there is complete loss of user funds. he can complete this attack by front running and then backrunning , means sandwiching user funds. this problem takes place , due to improper use of exchange rate when total supply is 0.
Root Cause
here root cause is total cash in formula is being calculated with balanceOF(address(this)), which can donated direclty too. and price can be inflated
Internal pre-conditions
No response
External pre-conditions
In this attack , attacker should be the first depositor, and while deploying on ethereum, he can frontrun and can be the first depositor.
Attack Path
while depositing when , total supply of minting token is 0, attacker will deposit , 1 wei of asset and will be minted with 1 wei of share.
so now total supply would be 1 wei.
now , he will wait for the first depositor , lets say first depsoit is 5e18 , and attacker will directly donates more than that amount , and now user tx would take place, but in result he will be minted with 0 shares , due to inflation in share price.
he can now, redeem his 1 wei of share, and in return he can get all amount of asset( donated+ 1 wei + user deposited)
in link we can see the formula which is being used for exchangerate.
Impact
this can lead user loss of funds, and attacker will get benefited from this.
PoC
No response
Mitigation
1000 wei ( some amount) shares should be burned while first depositing. this is done by uniswap too
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the exchange rate is computed using the contract's token balance, which can be increased by direct transfers, allowing manipulation when total supply is low.
Impact
The victim depositor suffers a complete loss of their deposited funds, while the attacker gains the entire vault balance without risking their own funds.
What the attacker needed
Attacker must be the first depositor; Attacker can front-run on Ethereum
The fix
The vault should burn a small number of shares (e.g., 1000 wei) on the first deposit to prevent share price inflation, as done by Uniswap.
How it was found
- Attacker becomes the first depositor by front-running, depositing 1 wei and receiving 1 wei of shares.
- Attacker waits for the next depositor to submit a deposit transaction.
- Attacker directly donates a large amount of the asset to the vault, inflating the share price.
- The victim's deposit transaction executes, but due to the inflated share price, the victim receives 0 shares.
- Attacker redeems their 1 wei of shares and receives the entire vault balance (donation + victim's deposit + 1 wei).
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A vault is like a shared savings account where your deposit buys shares. The share price is based on the total money in the vault divided by the number of shares. If someone can artificially inflate the total money (by donating directly to the vault), the share price becomes huge, so the next person's deposit buys almost zero shares. The attacker, who owns the only existing share, can then withdraw everything.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.