# Minted shares bypass lock check

Validation before lazy mint in transfer hooks; lock or first-deposit state set after the check passes

_Area: DeFi accounting and math bugs. Seen in 2 disclosed reports; latest 2026-08-20. Updated 2026-10-29._

## How it works
A token hook validates a condition (a lock, a first-deposit gate) and then, in the same call, lazily mints new shares whose state (lockedUntil, scaled balance) is set *after* the validation already ran. The subsequent balance move carries the just-minted shares past the check that was supposed to constrain them. The broken assumption: that the state read during validation reflects the state after the mint side-effect. It does not, because the mint happens between validation and the actual transfer.

## Where it shows up
- ERC-20 `_update`/`transfer` hooks that call a validation helper before a lazy `claimShares`/`_mint`.
- Lock or gate state (`lockedUntil`, `is_first_supply`) written inside or after the mint, not before.
- A single mode enum reused for both send and receive paths of a cross-chain handler.
- "First deposit" flags derived from a live token balance rather than a stored per-user/per-reserve flag.

## How to review
The invariant: any state that gates a transfer must be fully set before the transfer's balance movement, and must be re-evaluated against post-mint state. Check ordering in the hook: does validation run before or after the lazy mint? Does the mint set lock/gate state before `super._update` moves the shares? For cross-chain handlers, confirm the receive branch performs the inverse operation of the send branch for each mode. For first-deposit guards, confirm the flag is a stored initialization bit, not `balance == 0`.

## Variants seen
- Lock check precedes lazy mint; minted shares transfer out in the same call [E1](https://bugbountylibrary.com/r/sherlock%3A2025-07-mellow-flexible-vaults%3AM-6.md).
- Receive-side mode branch inverts LockMint/BurnUnlock semantics, making those modes non-functional [E2](https://bugbountylibrary.com/r/c4%3A2024-08-chakra%3AH-13.md).
- First-supply guard keyed off scaled balance; a dust transfer flips it and skips MIN_FIRST_DEPOSIT and oracle checks [E3](https://bugbountylibrary.com/r/c4%3A2026-04-k2%3AM-11.md).

## Impact and severity
Lockup bypass lets restricted shares move immediately, defeating vesting/lock guarantees [E1](https://bugbountylibrary.com/r/sherlock%3A2025-07-mellow-flexible-vaults%3AM-6.md). Inverted modes silently break cross-chain configurations [E2](https://bugbountylibrary.com/r/c4%3A2024-08-chakra%3AH-13.md). Skipped first-supply checks remove deposit minimums and oracle validation, enabling mispriced or dust initial supply [E3](https://bugbountylibrary.com/r/c4%3A2026-04-k2%3AM-11.md). Severity rises where the bypassed check protects pricing or collateral state, not just timing.

## Evidence
- E1: https://bugbountylibrary.com/r/sherlock%3A2025-07-mellow-flexible-vaults%3AM-6.md
- E2: https://bugbountylibrary.com/r/c4%3A2024-08-chakra%3AH-13.md
- E3: https://bugbountylibrary.com/r/c4%3A2026-04-k2%3AM-11.md
