# Malicious user can change the `TradeType` to steal funds from the vault or withdraw request manager

User-controlled tradeType in Notional Exponent redemption/staking trades lets attacker flip EXACT_IN to EXACT_OUT, buying excess asset tokens with vault funds.

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

**Target:** Solidity vault redemption and withdraw-request-manager trade execution
**Root cause:** _executeRedemptionTrades and _preStakingTrade pass caller-supplied t.tradeType/params.tradeType into _executeTrade instead of hardcoding EXACT_IN_SINGLE, so the amount field is interpreted as the exact buy amount rather than exact sell amount.
**Steps:**
1. Vault holds asset WBTC and secondary DAI; redemption yields 10,000 DAI + 1 WBTC.
2. Caller submits redemptionTrades with `tradeType=EXACT_OUT_SINGLE`, sellToken=DAI, buyToken=WBTC, amount=10000e18.
3. _executeRedemptionTrades builds Trade with that tradeType and amount=exitBalances[i].
4. _executeTrade treats amount as exact WBTC out (1.0e14 WBTC), pulling arbitrary DAI from vault balance.
5. Attacker receives far more WBTC than the 0.1 WBTC an EXACT_IN swap would yield; repeat on AbstractWithdrawRequestManager._preStakingTrade with USDC/staking token.
**How found:** Code review of _executeRedemptionTrades comment 'Always sell the entire exit balance' versus the fact that tradeType is taken from user-supplied TradeParams, spotting the semantic mismatch between EXACT_IN and EXACT_OUT amount interpretation.
**Exploitation:** Attacker crafts redemption/staking trade params with EXACT_OUT_SINGLE; the adapter pulls extra sell-token balance (e.g. reward DAI or finalized USDC in WRM) to deliver the exact buy amount, converting vault/WRM funds into asset or staking tokens credited to attacker.
**Escalation:** Same primitive applies across any DEX adapter and both yield-strategy vaults and withdraw request managers; 0x adapter allows arbitrary execution data for maximum flexibility.
**Insight:** When a function's comment states an invariant (sell entire balance) but the trade type/amount semantics come from caller input, check whether flipping EXACT_IN/EXACT_OUT reinterprets the amount field and lets the adapter pull more than the intended balance.

