Normal Behavior: The BriVault contract allows users to deposit ERC-20 tokens through the deposit() function, which calculates the number of shares to mint based on the deposited assets and total shares in the vault. _convertToShares() is responsible for this calculation.
Specific Issue: _convertToShares() uses IERC20(asset()).balanceOf(address(this)) instead of tracking internal vault assets. If a user sends ERC-20 tokens directly to the vault via transfer(), the balanceOf increases without increasing total shares. As a result, the attacker can mint an arbitrary number of shares, potentially inflating their holdings and enabling them to drain the vault.
Likelihood:
Users or attackers can send ERC-20 tokens directly to the vault at any time, bypassing the deposit() function.
_convertToShares() uses the raw balance for share calculation, which always occurs during deposit, making the vault immediately vulnerable.
Impact:
An attacker can mint 1000x more shares than intended, diluting other users and gaining an unfair portion of the vault assets.
The vault can be fully drained, resulting in complete loss of user funds.
Additional Recommendations:
Introduce an internal _totalAssets variable that is updated only on deposits/withdrawals.
Avoid using IERC20(asset()).balanceOf(address(this)) for share calculations.
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.