# Manipulation of total share amount might cause future depositors to lose their assets

Equity.calculateSharesInternal mints 1000e18-totalShares when supply dips below 1000e18, letting an attacker redeem 1 share so the next depositor gets 1 share for 1000 ZCHF.

- Payout: Contest reward
- Severity: medium
- Program: Frankencoin
- Credited: MiloTruck
- Disclosed: 2023-06-09
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2023-04-frankencoin-findings/issues/915
- Library page: https://bugbountylibrary.com/r/c4%3A2023-04-frankencoin%3AM-03
- Tags: domain:web3 impact:funds-loss kind:contest platform:code4rena sev:medium tech:evm tech:solidity technique:source-review vuln:accounting-error vuln:share-inflation

**Target:** Equity share-minting contract (Solidity)
**Root cause:** calculateSharesInternal special-cases totalShares < 1000e18 by minting up to 1000e18 shares regardless of deposit size, but redeem() only enforces a 1e18 floor, so supply can sit just below 1000e18.
**Steps:**
1. Alice deposits 1000 ZCHF via `transferAndCall(reserve, 1000e18, "")`, receiving 1000e18 shares.
2. Wait 90 days until `canRedeem` passes.
3. Alice calls `reserve.redeem(ALICE, 1)`, leaving totalSupply = 1000e18 - 1.
4. Bob deposits 1000 ZCHF; `calculateSharesInternal` returns `1000e18 - (1000e18-1) = 1` share.
5. Alice redeems her shares, capturing Bob's deposit; repeat by redeeming 1 share before each new depositor.
**How found:** Code reading of calculateSharesInternal's first-depositor bootstrap branch, noticing the 1000e18 threshold is inconsistent with redeem()'s 1e18 floor, then constructing a Foundry PoC.
**Exploitation:** Attacker holding shares redeems a single share to push totalSupply just below 1000e18, then each subsequent depositor receives only 1 share for their full deposit; attacker's shares redeem against the inflated capital, extracting the depositors' ZCHF.
**Escalation:** Repeat the 1-share redeem before each new deposit to keep supply below the threshold and drain successive depositors.
**Insight:** When a contract bootstraps shares with a minimum-supply special case, check whether any burn/redeem path can push supply back below that threshold; the floor enforced on redeem must match the bootstrap threshold.
