BriVault::cancelParticipation() does not update internal contract records, leading to stale participant data and broken accountingThe BriVault::cancelParticipation() function likely intends to allow users to “withdraw” or “opt out” of an event.
But, it does not remove the user’s address from the usersAddress array, nor does it decrement numberOfParticipants or reset related mappings such as userToCountry or userSharesToCountry.
Relevant vulnerable code section:
Likelihood:
Any user can trigger this behavior by calling cancelParticipation() after joining.
Impact:
usersAddress retains users who have already cancelled, producing stale data.
numberOfParticipants remains inflated, breaking metrics or share-based calculations.
totalParticipantShares may also remain inaccurate if not decremented.
Subsequent on-chain queries (e.g., for leaderboard or reward distribution) produce incorrect results.
The following test demonstrates the issue clearly:
After cancelParticipation(), user1 still appears as the first element in usersAddress.
numberOfParticipants remains 1.
The internal contract state suggests that the user is still participating.
Once a user cancels, they should be removed from usersAddress, numberOfParticipants should decrement by 1, and all user-related mappings (userToCountry, userSharesToCountry, etc.) should be reset.
Implement full participant record clean-up when cancelling participation.
This ensures the contract’s state remains synchronized and accurately reflects active participants.
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.