Sleepy Denim Guppy - Vault is vulnerable to inflation attack which can cause complete loss of user funds #253
Labels
Sponsor Confirmed
The sponsor acknowledged this issue is valid
Will Fix
The sponsor confirmed this issue will be fixed
Sleepy Denim Guppy
High
Vault is vulnerable to inflation attack which can cause complete loss of user funds
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
https://github.com/sherlock-audit/2024-12-numa-audit/blob/main/Numa/contracts/lending/CErc20.sol#L60C1-L63C6
https://github.com/sherlock-audit/2024-12-numa-audit/blob/main/Numa/contracts/lending/CToken.sol#L510C1-L515C1
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)
https://github.com/sherlock-audit/2024-12-numa-audit/blob/main/Numa/contracts/lending/CToken.sol#L374C4-L401C6
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
The text was updated successfully, but these errors were encountered: