The BriVault contract allows users to deposit assets to participate in a tournament, overriding deposit to track staked amounts in the stakedAsset mapping. Users can cancel participation before the event starts using cancelParticipation, which refunds the staked amount, burns all shares, and resets the mapping. The inherited ERC4626::withdraw function allows standard withdrawals based on share balance, transferring assets and burning shares accordingly.
However, neither withdraw nor cancelParticipation validates the state against the other, enabling a user to first call withdraw to burn shares and receive assets based on balance, then call cancelParticipation to receive an additional refund from stakedAsset without shares, resulting in a double withdrawal that drains the vault. This vulnerability allows MEV bots to backrun user deposits in the mempool, mimic the deposit amount, and perform the double withdrawal sequence repeatedly until eventStartDate is reached.
Likelihood:
Deposits occur in the mempool during the pre-event phase before eventStartDate.
MEV bots continuously monitor and backrun deposit transactions to replicate and exploit the sequence.
Impact:
Protocol experiences funds drain through repeated double withdrawals, leading to insolvency and zero rewards for legitimate participants.
Core tournament logic is compromised, causing users to lose deposits and eroding trust in the protocol.
Add the following code snippet to the briVault.t.sol test file.This test verifies that user can perform double withdraw sequentially calling ERC4626::withdraw and then BriVault::cancelParticipation.
Possible mitigation to override the standard function withdraw with similar to cancelParticipation logic or revert, preserving ERC4626 standard withdraw arguments.
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.