BriVault

First Flight #52
Beginner FriendlySolidity
100 EXP
View results
Submission Details
Severity: high
Valid

joinEvent() Uses balanceOf() Instead of stakedAsset() — Miscalculates totalWinnerShares and Unfair Withdrawals

Root + Impact

Description

  • Normal Behavior: Each participant’s voting power and potential winnings should be based only on their deposited amount (stakedAsset[msg.sender]). When calculating totalWinnerShares, the vault should count each user’s actual staked shares.

  • Specific Issue:
    In joinEvent(), the contract uses balanceOf(msg.sender) instead of stakedAsset[msg.sender] to determine the participant’s shares.
    Since balanceOf() reflects all shares minted plus any extra tokens indirectly affecting the vault balance, users can manipulate their balanceOf() by directly transferring ERC-20 tokens to the vault.
    This inflates totalWinnerShares, making the payout ratio in withdraw() unfair — honest users get less, and manipulators get more.

// joinEvent()
uint256 participantShares = balanceOf(msg.sender); // @> Wrong: includes inflated balance
userSharesToCountry[msg.sender][countryId] = participantShares;
totalWinnerShares += participantShares;

Risk

Likelihood:

  • High — Any user can perform this action b calling the deposit() then calling joinEvent()which leads to update of participationshare() whicg affects the value of the TotalWinnershare().

Impact:

  • Incorrect totalWinnerShares: Skews the reward distribution formula.

  • Unfair withdrawals: Honest participants receive less payout.

  • Economic loss: Vault payouts become unbalanced, leading to permanent loss of funds for fair users.


Proof of Concept

// Example Setup
// User A deposits 10 USDC
// Attacker deposits 5 USDC,
// joinEvent() uses balanceOf() → counts inflated balance for Attacker
// Final payout distribution
// User A expected high payout but since the attacker inflated the value to totalwinnershare()
// that effects the withdraw amount

Recommended Mitigation

- uint256 participantShares = balanceOf(msg.sender);
+ uint256 participantShares = stakedAsset[msg.sender];
Updates

Appeal created

bube Lead Judge 19 days ago
Submission Judgement Published
Validated
Assigned finding tags:

Inflation attack

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!