The overwriting of stakedAsset[] mapping in BriVault.sol::deposit() will cause a loss of funds for users as they will make multiple deposits before the event, and upon calling cancelParticipation(), only receive a refund for the last deposit amount, losing all previous deposits.
In BriVault.sol:207-237, the deposit() function has an accounting mismatch:
The issue is:
stakedAsset[receiver] is overwritten on each call (line 222: = assignment, not +=)
Shares are accumulated via _mint() (line 231)
This creates a mismatch where:
User deposits 3 times: 10 ETH, 20 ETH, 5 ETH (total ~34.475 ETH after fees)
stakedAsset[user] = 4.925 ETH (only last deposit minus fee)
balanceOf(user) = 34.475 shares (all deposits accumulated)
When cancelParticipation() is called (lines 275-289):
The contract burns all shares but only refunds the last deposit amount, permanently locking the difference.
The user suffers an approximate loss equal to all deposits except the most recent one. The lost funds become permanently stuck in the contract as there is no mechanism to recover them.
Example calculation:
Deposit 1: 10 ETH → 9.85 ETH net
Deposit 2: 20 ETH → 19.7 ETH net
Deposit 3: 5 ETH → 4.925 ETH net
Total deposited: 34.475 ETH net (35 ETH gross)
Refund received: 4.925 ETH
Loss: 29.55 ETH (~86% loss)
This vulnerability affects honest users who:
Want to increase their bet amount incrementally
Accidentally call deposit() multiple times
Receive tokens from others who deposit on their behalf
User makes multiple deposits, but stakedAsset[] is overwritten each time while shares accumulate.
When user cancels, they only receive refund for the last deposit amount, losing all previous deposits.
Change stakedAsset[] assignment to accumulate instead of overwrite:
This ensures that stakedAsset[] correctly tracks the cumulative net deposits, matching the accumulated share minting behavior.
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.