# Lender transactions can be front-run, leading to lost funds

mintViaUnderlying skips minImpliedRate slippage check when fCashAmount exceeds maxFCash, so a front-run mint forces lenders to lend at zero and lose funds.

- Payout: Contest reward
- Severity: high
- Program: Notional Update 5
- Credited: bin2chen
- Disclosed: 2023-12-20
- Write-up quality: 7/10
- Original: https://github.com/sherlock-audit/2023-12-notional-update-5-judging/issues/6
- Library page: https://bugbountylibrary.com/r/sherlock%3A2023-12-notional-update-5%3AH-1
- Tags: domain:web3 impact:funds-loss kind:contest platform:sherlock sev:high tech:evm tech:solidity technique:race-window technique:source-review vuln:business-logic

**Target:** wrapped-fcash wfCashLogic.mintViaUnderlying / _mintInternal
**Root cause:** In _mintInternal, the branch where maxFCash < fCashAmount (lending at zero) never validates minImpliedRate, so the caller's slippage protection is silently dropped once available fCash is exhausted.
**Steps:**
1. Lender calls `mintViaUnderlying(5000e18, 5000e8, LENDER, 0.15e9)` while maxFCash >= 5000e8; it reverts with 'Trade failed, slippage'.
2. Attacker front-runs with `w.mint(5000e8, alice)` to consume available fCash so maxFCash < fCashAmount.
3. Lender's same `mintViaUnderlying` now enters the `maxFCash < fCashAmount` branch, skips minImpliedRate, and succeeds lending at zero rate.
4. Lender receives wfCash but pays full deposit at zero implied rate, losing yield/funds.
**How found:** Code review of _mintInternal noticed the `maxFCash < fCashAmount` branch lacks the minImpliedRate check present in the normal path; Foundry test confirmed the tx reverts with slippage alone but succeeds after a front-run mint.
**Exploitation:** Attacker observes a pending lender mintViaUnderlying with a minImpliedRate, front-runs with a mint to push maxFCash below the lender's fCashAmount, causing the victim tx to execute in the unchecked 'lending at zero' branch and accept a zero interest rate.
**Insight:** When a function has multiple branches, check that every branch enforces the same slippage/limit guards; a fallback 'lending at zero' path that skips minImpliedRate is a front-runnable griefing vector.
