# ElixirStrategy wrong withdrawal accounting allows undercollateralized borrowing

ElixirStrategy computed withdrawnAmount from a zero balanceBefore, counting the user's pre-existing holding tokens as yield and inflating collateral to over-borrow jUSD.

- Payout: Contest reward
- Severity: high
- Program: Jigsaw
- Credited: 0xl33
- Disclosed: 2025-08-11
- Write-up quality: 7/10
- Original: https://cdn.cantina.xyz/reports/cantina_competition_jigsaw_june2025.pdf#3.1.4
- Library page: https://bugbountylibrary.com/r/cantina%3Ajigsaw_june2025%3A3.1.4
- Tags: domain:web3 impact:funds-loss impact:integrity kind:contest platform:cantina sev:high tech:solidity technique:source-review vuln:accounting-error vuln:business-logic vuln:oracle-manipulation

**Target:** ElixirStrategy withdraw accounting / SharesRegistry collateral
**Root cause:** withdraw() computes withdrawnAmount as balanceOf(_recipient) - params.balanceBefore but balanceBefore is never set (stays 0), so the recipient's entire pre-existing token balance is counted as strategy yield.
**Steps:**
1. Deposit large amount (e.g. 100,000e6 USDT) into user holding via initiateUser.
2. Invest minimal amount (1e6) into ElixirStrategy via strategyManager.invest.
3. Cooldown shares, skip 7 days, then strategyManager.claimInvestment with all shares.
4. withdrawnAmount = balanceOf(holding) - 0 = full holding balance, so SharesRegistry credits ~185001e6 collateral vs ~85001e6 actual tokens.
5. Call holdingManager.borrow(tokenIn, 92500e6, 0, true) — exceeds the ~50000e6 allowed by 50% collateralization rate.
**How found:** Code review of withdraw() spotted params.balanceBefore used in subtraction but never assigned, tracing how withdrawnAmount feeds SharesRegistry collateral accounting.
**Exploitation:** Attacker deposits large USDT into holding, invests a tiny amount into the strategy, withdraws all shares; the inflated withdrawnAmount is booked as yield/collateral, letting them borrow ~92500e6 jUSD against ~50000e6 legitimate capacity, leaving bad debt.
**Escalation:** Repeatable per holding and across users; mass insolvency if scaled.
**Insight:** In strategy/yield accounting, grep for `balanceBefore`/`balanceAfter` delta patterns and verify the snapshot is actually assigned before the transfer; uninitialized snapshot fields silently turn recipient balances into fake yield.
