The BriVault contract performs external ERC20 calls before updating internal accounting, and it does so without a reentrancy guard.
Vulnerable patterns appear in both:
1.deposit()
A malicious ERC20 token can execute a callback inside transferFrom(), calling deposit() again before:
stakedAsset[msg.sender] is updated properly
participantShares is minted
invariant checks are enforced
This allows attackers to manipulate share minting ratios (classic ERC4626 share inflation).
withdraw():
Attackers can re-enter during safeTransfer before state is fully updated, withdrawing multiple times or pulling more than their share of the vault.
Root Cause
External calls (safeTransferFrom, safeTransfer) occur
No nonReentrant modifier
Internal accounting not updated before external interaction
ERC4626 math depends on vault balances → easily manipulated during reentrancy
This exposes classical ERC4626 share inflation, double withdraw, and state corruption vectors
Reason 1:
The vault supports arbitrary ERC20 tokens, meaning an attacker may provide a malicious token that triggers reentrant callbacks.
Reason 2:
Both deposit and withdraw paths make external calls before effects, providing exploitable entry points for reentrancy.
The reentrancy vector in deposit(), cancelParticipation(), and withdraw() exposes BriVault to direct fund loss, corrupted share accounting, and broken winner payout logic. Because BriVault performs external ERC20 calls before updating critical internal state, a malicious token or contract-controlled address can reenter the vault mid-execution and:
bypass participation checks,
inflate shares,
withdraw more than entitled, or
drain the vault before winner finalization.
Since BriVault is a tournament-based vault where accurate share accounting determines reward distribution, any reentrant manipulation directly compromises fairness, reward integrity, and total asset correctness. This risk impacts the core economic mode
Impact 1:
An attacker can mint more shares than intended by re-entering during deposit() before internal accounting is updated (ERC4626 inflation exploit).
Impact 2:
In withdraw(), attackers can withdraw multiple times or manipulate payout amounts before the function completes.
Severity: Medium → High depending on asset trust model.
Since vault allows arbitrary ERC20 transfer callbacks,
Add this PoC to your existing BriVaultTest
It uses a malicious token that re-enters deposit() during transferFrom, minting extra shares
Malicious Reentrancy Token
Create a malicious token:
PoC Test
What this demonstrates
transferFrom() re-enters deposit()
Internal state is inconsistent during reentrancy
User receives extra ERC4626 shares
Vault accounting becomes corrupted
This matches historical ERC4626 reentrancy attacks (e.g., TempleDAO, Midas, Alchemix).
1. Add Reentrancy Guard
Apply it to:
2. Use Checks-Effects-Interactions
*Rewrite deposit:
3. Reject Malicious Tokens (Optional)
If intended only for standardized ERC20s:
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.