Hooks.wtf

Zaps

LaunchZap.sol

LaunchZap combines a launch with optional prebuys and refunds unused native funds. The finding below covers a pre-existing balance forcing a refund to a caller that cannot receive ETH.

Reviewed source: src/zaps/LaunchZap.sol at commit 38f14ff.

Findings

IDSeverityFinding
B-17LowA 1 wei donation can block LaunchZap callers that cannot receive ETH

[LOW] B-17 · A 1 wei donation can block LaunchZap callers that cannot receive ETH

B-17 · Low

LaunchZap refunds its entire native balance. A donation therefore forces a refund even when the next caller expected no ETH back, reverting callers that cannot receive it.

LaunchZap finishes every launch with _finish(0). The shared helper computes the refund as the zap's current ETH balance minus that retained balance and sends it to the original caller.

The zap also has an open receive function. Anyone can send it 1 wei before a launch. If the next caller is a contract without a payable receiver, refunding that unrelated donation reverts the entire launch.

Impact

An attacker can grief launches made by contracts that cannot receive ETH, using only a dust donation. EOAs and payable callers can accept the refund and are unaffected. The failure does not divert the launcher's funds.

Affected code

Locations refer to the reviewed commit, 38f14ff.

From src/zaps/LaunchZap.sol:54–56:

}
// A zero retained balance preserves the original refund-all behavior.
_finish(0);

From src/zaps/abstract/SwapZapBase.sol:227–235:

function _finish(uint _nativeBalanceBefore) internal {
    uint refund = address(this).balance - _nativeBalanceBefore;
    if (refund != 0) {
        // The destination is fixed to the original caller that funded this operation.
        // forge-lint: disable-next-line(arbitrary-send-eth)
        SafeTransferLib.safeTransferETH(_caller, refund);
    }
    _clearOperation();
}

Proof of concept

ZapsPoC.t.sol::test_Z05_oneWeiDonationRevertsLaunchesFromNonPayableCallers donates 1 wei to the zap, then launches from a contract that cannot receive ETH. The launch reverts at the refund. Removing the unrelated donation avoids that forced refund.

The test source is poc/ZapsPoC.t.sol in the Solidity evidence bundle. Follow the reproduction setup, then run:

FOUNDRY_GAS_LIMIT=1000000000000 forge test --match-path 'test/audit/ZapsPoC.t.sol' -vv

Snapshot the native balance before the operation, excluding msg.value, and pass that snapshot to _finish. TrustedSignerZap already uses this pattern. Only the current caller's unused budget should be refunded.

Shared findings

Previous
AtomicLaunchZap.sol