briVault::_convertToShares function allows the firstDepositor to get 1:1 share ratio upon deposit.
This vulnerability allows an attacker to make a very small initialDeposit and then transfer tokens directly to the vault (without using briVault::deposit), enabling them to manipulate subsequent depositors' shares and steal their funds.
Likelihood:
Once the deployment time becomes public attacker will know about the first deposit time.
Attacker can monitor the mempool to see the first legitimate deposit transaction and front-run it with a higher gas fee.
In multiple tournament deployments (WorldCup, Olympics, Racing), the attack opportunity arises again for each new contract.
Impact:
Subsequent depositors might lose their funds due to manipulated share ratio
Attacker, might exploit 100% of subsequentDepositors assets
The protocol's reputation is completely compromised
Once the attack is discovered after the event has started, the protocol cannot recover because all participants will have lost their funds.
Attacker either:
monitors the mempool for the first legit deposit & front-run it with minimumAmount deposit or
if the contract deployment time is public, attacker deposits minimumAmount to benefit 1:1 raito
Transfer large amount to the vault immediately
Subsequent depositors receive 0 shares due to rounding
shares = (assets * totalShares) / balanceOfVault
assets * totalShares goes down
balanceOfVault rises
shares becomes less than 1 which will round down to zero as a natural division behaviour in Solidity.
Note: Although Math.mulDiv() is used to calculate shares. It will only be a guard against overflow not the inflation attack.
There are several mitigations to prevent this attack but it is best practice to add virtual shares. Assert the followings within briVault.sol:
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.