Description:
Both deposit and redeem functions in VaultRouterBranch.sol interact with external IERC4626 token contracts (indexToken). Specifically, they call IERC4626(indexTokenCache).deposit(...) in deposit and IERC4626(indexToken).redeem(...) in redeem.
impact:
These calls transfer tokens into and out of the VaultRouterBranch contract, respectively. If the indexToken contract is a malicious or vulnerable contract, it could potentially perform a reentrant call back into the VaultRouterBranch contract during these deposit or redeem operations.
Proof of Concept:
In deposit:
User calls deposit in VaultRouterBranch.sol.
VaultRouterBranch.sol transfers deposit assets from user to VaultRouterBranch.sol using safeTransferFrom.
VaultRouterBranch.sol approves indexToken contract to spend assetsMinusFees.
VaultRouterBranch.sol calls IERC4626(indexTokenCache).deposit(ctx.assetsMinusFees, msg.sender);
Reentrancy Point: If the indexToken contract's deposit function (or any function it calls internally during deposit) performs a callback to VaultRouterBranch.sol (e.g., by calling a function that updates vault state or initiates another deposit/redeem operation), reentrancy can occur
In redeem:
User calls redeem in VaultRouterBranch.sol.
VaultRouterBranch.sol calculates redeem amount and redeem fee.
VaultRouterBranch.sol calls IERC4626(indexToken).redeem(ctx.sharesMinusRedeemFeesX18.intoUint256(), msg.sender, address(this)).
Reentrancy Point: If the indexToken contract's redeem function (or any function it calls internally during redeem) performs a callback to VaultRouterBranch.sol, reentrancy can occur.
VaultRouterBranch.sol then further calls IERC4626(indexToken).redeem(...) again to redeem fees. This second redeem call within the same redeem function significantly increases the reentrancy risk, as a malicious indexToken can potentially re-enter and exploit state inconsistencies between the two redeem calls or before/after either of them.
Recomended Mitigation:
Implement Reentrancy Guard: implement OpenZeppelin's ReentrancyGuard modifier on both deposit and redeem functions in VaultRouterBranch.sol
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.