The BriVault::deposit function accepts two parameters: assets (the deposit amount) and receiver. The receiver parameter allows a user to deposit tokens while assigning the resulting vault shares to a different address.
The issue in the BriVault::deposit function occurs during the share minting process. Specifically, while the mapping BriVault::stakedAsset is correctly updated with the BriVault::receiver address, the minted shares are sent to msg.sender instead of the intended BriVault::receiver.
Likelihood:
This issue occurs every time a user calls BriVault::deposit with a BriVault::receiver address different from their own.
When the BriVault::receiver is the same as msg.sender, the behavior is correct; however, if they differ, the minted shares are incorrectly assigned to msg.sender instead of the specified BriVault::receiver.
Impact:
This bug allows a receiver who does not actually hold any BriVault:shares to call the BriVault:joinEvent function, while preventing the user who originally called the BriVault:deposit function from participating — even though they do possess the BriVault:shares.
When BriVault:withdraw is executed, part of the funds become irretrievable, since these BriVault:shares are excluded from the reward distribution calculation, leading to a permanent loss of assets.
Add this code snippet to the provided test file.
This test verifies the mismatch between the shares actually held and the mapping that tracks staked assets. It also demonstrates how a user who possesses shares cannot participate due to this mismatch, while a user who does not actually hold any shares can participate even though they should not be able to.
To prevent this issue, the _to parameter in the BriVault::_mint call should be replaced with receiver instead of msg.sender.
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.