# Buyout Module: redeeming before the update of totalSupply will make buyout's current state success

FERC1155.mint updates totalSupply after _mint's external callback, letting a malicious receiver redeem early and mark a vault's buyout SUCCESS, then drain assets.

- Payout: Contest reward
- Severity: medium
- Program: Fractional
- Credited: zzzitron
- Disclosed: 2022-09-27
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2022-07-fractional-findings/issues/574
- Library page: https://bugbountylibrary.com/r/c4%3A2022-07-fractional%3AM-05
- Tags: domain:web3 impact:funds-loss kind:contest platform:code4rena sev:medium tech:evm tech:solidity technique:chained technique:source-review vuln:accounting-error vuln:business-logic vuln:reentrancy

**Target:** FERC1155 mint / Buyout module redeem state
**Root cause:** FERC1155.mint calls _mint (which invokes an external callback to the receiver) before incrementing totalSupply, so a reentrant redeem sees zero supply and sets buyout state to SUCCESS prematurely.
**Steps:**
1. Deploy `evil_redeemer` contract that deploys a vault and calls `redeem` in its FERC1155 receive hook
2. Call `start` -> `baseVault.deployVault` deploys vault and mints FERC1155 to `evil_redeemer`
3. During `_mint` callback, `evil_redeemer.redeem` executes while `totalSupply` is still 0, setting buyout state to `SUCCESS`
4. After callback returns, `totalSupply[_id] += _amount` is applied
5. Attacker deposits assets, sells fractions to victims, then withdraws all vault assets anytime via buyout module since state is already SUCCESS
**How found:** Code reading of FERC1155.mint ordering: noticed totalSupply updated after _mint, and _mint makes an outgoing call to receiver when codesize nonzero, enabling reentrancy into redeem.
**Exploitation:** Attacker-controlled receiver contract reenters redeem during mint to force buyout SUCCESS state, then sells fractions to unsuspecting buyers who only inspect vault (not buyout module status) and withdraws the vault's assets.
**Insight:** When a token's supply accounting is updated after an external mint callback, check every consumer that reads totalSupply during that window (e.g. redeem/state machines) for reentrancy that can lock in a privileged state before supply is recorded.
