In a standard ERC-4626 vault, the deposit() function is expected to transfer assets from the depositor (msg.sender) and mint the corresponding vault shares to the specified receiver. This enables third-party deposits, preserves accounting consistency, and maintains compliance with the ERC-4626 specification.
In BriVault.deposit(), the implementation incorrectly mints vault shares to msg.sender instead of receiver. This creates a logical mismatch because the function records stakedAsset under receiver but grants the minted shares to msg.sender. As a result, the vault’s internal accounting becomes inconsistent: stakedAsset[receiver] and balanceOf(receiver) no longer represent the same participant. This breaks subsequent functions like joinEvent(), cancelParticipation(), and withdraw() that assume these two mappings belong to the same user.
Likelihood:
This occurs whenever a user deposits assets into the vault, the error is inherent in every deposit call.
Any function relying on stakedAsset[msg.sender] and balanceOf(msg.sender) alignment (like joinEvent() and withdraw()) will behave incorrectly.
Impact:
The participant recorded as a depositor (receiver) will not receive vault shares, causing a mismatch between stakedAsset[receiver] and balanceOf(receiver). As a result, the legitimate participant will fail checks such as stakedAsset[msg.sender] == 0 in joinEvent() and cancelParticipation(), preventing them from joining the event or withdrawing their stake.
The depositor (msg.sender), who incorrectly receives the shares via _mint(msg.sender, participantShares), can still call functions like balanceOf(msg.sender), withdraw(), and cancelParticipation() to interact with the vault as if they were the rightful participant. This misalignment allows unauthorized withdrawals, incorrect reward claims, and potential total loss of funds belonging to the actual participant (receiver).
The proof of concept shows that when one user deposits on behalf of another, the receiver is recorded as the participant but does not receive shares, breaking subsequent participation and withdrawal logic.
Additionally, consider accumulating staked amounts to prevent overwriting:
Mint vault shares to the specified receiver instead of msg.sender to align with ERC-4626 standards and ensure consistent ownership and accounting.
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.