userToCountry mapping details allows user to cancel participation but go ahead and withdraw winnings.The cancelParticipation function has a critical vulnerability where it does not update userToCountry mapping details when a user cancels participation, plus, before burning shares, it just checks the balance of shares of the user instead of the shares they received, then refunds them with the staked amount.
An attacker can exploit this vulnerablility by:
Taking a flashloan, deposits and joins event
Transfers all shares received to another wallet they control
Cancles participation, is refunded but burns zero shares
Repays loan (Attacker here pays the fees for the deposit back)
Transfers shares back to their wallet.
Other users deposit and join event
Admin sets winner
Attacker withdraws winnings despite having been refunded because their userToCountry were not updated on cancelling the participation.
Likelihood:
This happens when a user trnasfers shares to another wallet they control and then cancel participation from the wallet holding assets.
Impact:
High
Attacker withdraws assets despite having cancelled the participation.
Attacker reduces the winnings of other users.
Add this test to briVault.t.sol and run forge test --mt testWithdrawAfterCancellingParticipation -vvvv
On cancelling a user's participation, always update userToCountry mapping details
In addition, convert the amount to refund to shares and then burn, if a user has less shares than required, revert.
CancelParticipation burns shares but leaves the address inside usersAddress and keeps userSharesToCountry populated.
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.