Any user can deposit assets using the briVault::deposit() function. Those assets get stored under briVault::stakedAsset() mapping, and the shares are minted accordingly.
But there lies a small vulnerability that causes a lot of chaos for the users. Actually, when a user calls deposit(), their new assets overwrite the previous ones. That's because on line 222, stakedAsset[receiver] = stakeAsset;.
Due to this, whenever a user decides to deposit again, their already deposited assets won't be tracked. And whenever he decides to opt out of the event, he won't get enough refunds. Technically, his assets will be stuck. The thing to note here is, this contract doesn't restrict anyone from depositing again, so yeah, that's quite a likely scenario to happen with many users.
In the worst scenario, a malicious actor can overwrite someone else stakedAsset by calling deposit() with receiver = victim. Thus, making the victim's assets stuck, intentionally.
Likelihood: High/Medium
If the users aren't aware of this issue, they can easily make such blunders.
Doesn't restrict anyone from calling this function again and again.
Interestingly, a malicious actor can also overwrite someone else stakedAsset easily.
Impact: High/Medium
Doesn't harm the protocol at that level atleast, just makes the day difficult for the user.
At some point, the protocol will have a lot more assets than shares.
Provides an opportunity for malicious actors to force users to play the tournament by overwriting their assets. With this, the victims can't leave the tournament of their own will; otherwise, they will suffer losses.
Erodes trust in the system.
A simple PoC showing:
How a user wants to make a deposit again, but mistakenly overwrites his previous deposit, he can incur a loss when opting out of the tournament.
A malicious actor intentionally overwrites someone's huge staked assets into the system with a small amount, forcing him to stay in the tournament.
Add this test_StakedAssetsGetsOverwrites test to briVault.t.sol:
Run the above test using the following command:
Logs:
Rather than overwriting, the new deposits should be added to the previous ones. Hence, make this fix:
Vault tracks only a single deposit slot per user and overwrites it on every call instead of accumulating the total.
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.