# Cross-contract reentrancy allows YIELD_TOKEN theft for the `GenericERC4626` `WithdrawalRequestManager` variant

Cross-contract reentrancy in Notional's GenericERC4626 WithdrawalRequestManager lets an attacker inflate YIELD_TOKEN delta during stakeTokens, minting excess shares and stealing other users' pending redemption tokens.

- Payout: Audit contest
- Severity: high
- Program: Notional
- Found by: 0xBoraichoT
- Disclosed: 2025-06-27
- Write-up quality: 8/10
- Original: https://github.com/sherlock-audit/2025-06-notional-exponent-judging/issues/73
- Library page: https://bugbountylibrary.com/r/sherlock%3A2025-06-notional-exponent%3AH-1
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:sherlock sev:high tech:evm tech:solidity technique:chained technique:source-review vuln:accounting-error vuln:reentrancy

**Target:** GenericERC4626WithdrawRequestManager.stakeTokens / AbstractYieldStrategy mintShares via Uniswap V3 multihop swap callback
**Root cause:** stakeTokens snapshots initialYieldTokenBalance before _preStakingTrade; the Uniswap V3 multihop path allows an attacker-controlled middle pool whose token callback reenters initiateWithdraw on a different approved vault, transferring YIELD_TOKENs into the manager so the post-trade balance delta (and thus minted shares) is inflated.
**Steps:**
1. Attacker deploys fake ERC20 token and a Uniswap V3 pool for it, and gets a vault whitelisted (or uses existing approved vault).
2. Victim calls initiateWithdraw, leaving spare YIELD_TOKENs in the GenericERC4626 WithdrawalRequestManager.
3. Attacker calls enterPosition/mintShares with depositData containing a multihop path `[deUSD, fee, USDC, fee, tokenIn, fee, fakeToken, fee, tokenIn]` where fakeToken's transfer hook reenters.
4. During the swap, fakeToken.transfer calls back into a second approved vault's initiateWithdraw, moving YIELD_TOKENs into the manager mid-trade.
5. stakeTokens computes yieldTokensMinted = balanceOf(this) - initialYieldTokenBalance, capturing the reentrantly-added tokens as delta.
6. Attacker receives inflated shares, then redeems/burns them against the manager's staked assets, draining other users' pending YIELD_TOKENs.
**How found:** Auditor noticed stakeTokens lacks nonReentrant and snapshots balance before an external Uniswap swap; observed that only first/last path tokens are validated, allowing an attacker-controlled middle pool to serve as a reentrancy callback into initiateWithdraw on a different approved vault.
**Exploitation:** Attacker uses an EIP-7702-delegated EOA (or contract) to enter a position with a crafted Uniswap V3 multihop path containing an attacker-controlled pool; the fake token's transfer hook reenters initiateWithdraw on a second approved vault, inflating the YIELD_TOKEN delta measured by stakeTokens and minting excess shares that are then redeemed for underlying staking assets belonging to other users' pending withdrawals.
**Escalation:** Targeting forceWithdraw can further amplify the artificially earned delta.
**Insight:** When a contract measures a token balance delta around an external swap, check whether the swap path is fully validated — an attacker-controlled middle pool/token can reenter and pollute the delta. Cross-contract reentrancy applies when a shared manager serves multiple vaults and only per-call nonReentrant guards exist.

## Proof of concept (copied exactly from the original report)

**Malicious multihop swap path with attacker token**

```
bytes memory dataClaimInvest = abi.encode(
            amount * 99 / 100, // amountOutMinimum
            uint256(block.timestamp), // deadline
            abi.encodePacked(deUSD, poolFee, USDC, poolFee, tokenIn,
                // note how the control is temporary transferred to the attacker's token:
                poolFee, fakeToken, poolFee, tokenIn)
        );
```

**Attacker EOA code injection via vm.etch**

```
deal(tokenIn, user, 100e6, true);
        vm.etch(user, address(code).code);
        fakeToken.callme(user);
```

**Malicious pool creation for reentrancy callback**

```
p.createPoolAndMint(PoolCreator.CreateArgs({
                tokenA: IERC20(tokenIn),
                tokenAAmount: 1e6,
                tokenB: fakeToken,
                tokenBAmount: 1000e18,
                fee: poolFee,
                factory: IUniswapV3Factory(IPeripheryImmutableState(uniswapRouter).factory())
            }));
            vm.stopPrank();
        }
```

