InsuranceFund depositors can be priced out & deposits can be stolen
The InsuranceFund deposit function mints shares based on the contract's VUSD balance, allowing an attacker to inflate the share price and steal deposits. An attacker can deposit a tiny amount, directly transfer a large amount of VUSD to the contract, causing subsequent deposits to mint zero shares, then withdraw their single share to take the entire pool balance.
Submitted by cmichel, also found by danb
The InsuranceFund.deposit function mints initial shares equal to the deposited amount.
The deposit / withdraw functions also use the VUSD contract balance for the shares computation. (balance() = vusd.balanceOf(address(this)))
It’s possible to increase the share price to very high amounts and price out smaller depositors.
Proof of Concept
deposit(_amount = 1): Deposit the smallest unit of VUSD as the first depositor. Mint 1 share and set the total supply and VUSD balance to1.- Perform a direct transfer of
1000.0VUSD to theInsuranceFund. Thebalance()is now1000e6 + 1 - Doing any deposits of less than
1000.0VUSD will mint zero shares:shares = _amount * _totalSupply / _pool = 1000e6 * 1 / (1000e6 + 1) = 0. - The attacker can call
withdraw(1)to burn their single share and receive the entire pool balance, making a profit. (balance() * _shares / totalSupply() = balance())
I give this a high severity as the same concept can be used to always steal the initial insurance fund deposit by frontrunning it and doing the above-mentioned steps, just sending the frontrunned deposit amount to the contract instead of the fixed 1000.0. They can then even repeat the steps to always frontrun and steal any deposits.
Recommended Mitigation Steps
The way UniswapV2 prevents this is by requiring a minimum deposit amount and sending 1000 initial shares to the zero address to make this attack more expensive. The same mitigation can be done here.
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 share price calculation uses the contract's token balance, which can be inflated by direct transfers, without a minimum deposit or initial share burn.
Impact
An attacker could steal the initial insurance fund deposit and potentially repeat the attack to steal any deposits by frontrunning them.
What the attacker needed
Attacker is first depositor; attacker can directly transfer VUSD
How it was found
- Deposit the smallest unit of VUSD as the first depositor, minting 1 share.
- Directly transfer a large amount of VUSD to the InsuranceFund, increasing its balance.
- Subsequent deposits of less than the inflated amount mint zero shares.
- The attacker withdraws their single share to receive the entire pool balance.
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.
This is a smart contract bug where the value of a share in a fund can be manipulated. An attacker puts in a tiny amount first, then sends a large amount directly to the fund, making each share very expensive. Later depositors get zero shares for their money, and the attacker can 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.