Crypto Training

Gas Griefing and Untrusted Reverts: Liveness Is a Security Property

Withdrawals, liquidations and settlement can be stopped by a callee that reverts, a relayer that supplies too little gas, or a callback that returns too much data. This post covers push payments, the 63/64 rule, returndata bombs, the limits of try/catch and unbounded loops, with incidents and measured numbers.

Crypto Training•2026-02-03•11 min read

An attacker who cannot take funds can often still stop them from moving, and that usually costs less. It takes a contract that reverts when it is paid, a relayer that supplies slightly too little gas, or a callback that returns 300 KB of zeroes. When the function being stopped is a withdrawal, a liquidation or a settlement step, the outcome is locked funds or bad debt, so these paths deserve the same scrutiny as the ones that move money.

The review method is short. For each function that must stay callable, list the external calls it makes and ask of each one who controls the callee, and what happens to every other user when that callee fails or misbehaves.

Who can veto progress#

External interactionHow the callee stops youExample
ETH pushed to a recipientreverts when it receives ETHAkutars refund loop, April 2022
Token pushed to a recipienta blocklist or pause makes the transfer revertFactoryDAO finding, 2022
Call relayed with a gas limitthe relayer supplies too little gas for the inner callDecent finding, 2024
Callback with a gas caplarge return or revert data makes the caller payGMX Synthetics finding, 2023
Loop over an array users can growthe work exceeds what one transaction may useValkyrie hook finding, 2025
Oracle readreverts, or returns a stale value that a check rejectsL2 oracle failure modes

Push payments#

The oldest version of this bug has two halves, and fixing the first one naively produces the second.

King of the Ether Throne, in February 2016, paid the outgoing monarch with send, which forwards 2300 gas. Recipients that were contract wallets needed more than that, so the payment failed, and because the contract did not check the result it carried on and crowned the new monarch anyway. The post-mortem describes compensation left stranded in the contract.

The standard advice that followed was to check the result. A contract that checks it with require hands the recipient a veto instead, which is what Akutars shipped six years later.

SOLIDITY
// VULNERABLE: one reverting recipient blocks every refund, including the ones before it.
function processRefunds() external {
    for (uint256 i = refundCursor; i < bids.length; ++i) {
        Bid memory b = bids[i];
        (bool sent,) = b.bidder.call{value: b.paid - finalPrice}("");
        require(sent, "refund failed");
    }
    refundCursor = bids.length;
}

Any bidder that is a contract with a reverting receive makes this function revert for everyone. The Akutars auction had this shape in processRefunds(), and it had a second, independent bug in the owner's withdrawal, which required a counter of processed bidders to reach a counter of bids. Those two numbers measure different things, so the condition could never hold once anyone bought more than one NFT. The contract still holds 11,539.5 ETH, as an eth_getBalance call confirmed on 24 November 2026.

The fix is to record what is owed and let each recipient collect it, with a bound on the work per call.

SOLIDITY
// Bounded work per call, and nothing is sent.
function settleRefunds(uint256 maxCount) external {
    uint256 i = refundCursor;
    uint256 end = i + maxCount;
    if (end > bids.length) end = bids.length;
    for (; i < end; ++i) {
        owed[bids[i].bidder] += bids[i].paid - finalPrice;
    }
    refundCursor = i;
}

// A failing transfer affects only the claimant.
function claim() external {
    uint256 amount = owed[msg.sender];
    owed[msg.sender] = 0;
    (bool sent,) = msg.sender.call{value: amount}("");
    require(sent, "claim failed");
}

Tokens have the same problem without any hostile contract. USDC and USDT can block an address, and a function that must transfer to that address then reverts. In the FactoryDAO finding, a user deposits 1 wei and is later blocked, the pool can never pay that user out, and the owner's withdrawal of excess rewards requires all deposits to be cleared, so the owner's funds stay locked as well. The token integration checklist covers the token side, and the liquidation post covers what this means when the blocked step is a liquidation.

The 63/64 rule and under-gassed calls#

Since EIP-150, a call can receive at most "all but one 64th" of the gas remaining in the caller. A call that asks for more is silently given that maximum, and the caller keeps the last 64th to finish its own work.

That retained 64th is what makes the following pattern exploitable. A relayer, keeper or bundler chooses the gas limit of the outer transaction, so it can choose a limit at which the inner call runs out of gas while the outer function still completes.

sequenceDiagram participant R as Relayer participant F as Forwarder participant T as Target R->>F: execute(message) with a low transaction gas limit F->>F: mark message as executed F->>T: call with the gas limit named in the message Note over F,T: EIP-150 forwards at most 63/64 of what is left T-->>F: out of gas, the call returns false F->>F: emit Executed(id, false) using the retained 1/64 F-->>R: transaction succeeds Note over R,T: the message is consumed and the action never ran
SOLIDITY
// VULNERABLE: the relayer picks the transaction gas, and a failed call still consumes the message.
function execute(Message calldata m) external {
    require(!executed[m.id], "replayed");
    executed[m.id] = true;
    (bool ok,) = m.target.call{gas: m.gasLimit}(m.data);
    emit Executed(m.id, ok);
}

We ran this contract in Foundry with solc 0.8.28 against a target that needs about 270,000 gas and a message asking for 300,000. Every transaction gas limit we tried between 135,000 and 275,000 marked the message as executed without the target having run. The attack works whenever the rest of the outer function is cheap compared with a 64th of the inner budget, which is the usual case for large gas limits.

Two families of fix exist. The first proves that the callee received its gas. OpenZeppelin's ERC2771Forwarder measures gas immediately after the call, and the version below follows its _checkForwardedGas.

SOLIDITY
address target = m.target;
uint256 gasLimit = m.gasLimit;
bytes memory data = m.data;
bool ok;
uint256 gasAfter;
assembly ("memory-safe") {
    // Output size 0, so no return data is copied.
    ok := call(gasLimit, target, 0, add(data, 0x20), mload(data), 0, 0)
    gasAfter := gas()
}
// If the callee was given less than gasLimit and used all of it,
// less than gasLimit / 63 remains here.
if (gasAfter < gasLimit / 63) {
    assembly ("memory-safe") { invalid() } // consume all gas, so nothing is recorded
}

With this check the under-gassed transaction reverts and the message stays available. Optimism's SafeCall library takes the other route and checks before the call that enough gas is present, with a formula that accounts for the 63/64 split and a fixed buffer.

The second family makes failure harmless by keeping a failed message retryable. That choice needs care when messages are ordered, because a message that can never succeed then blocks the queue. The Decent finding in the table describes that case in a bridge, where the user chooses the destination gas with no minimum, an under-funded message fails on arrival, and the messaging layer stores it and blocks the channel behind it.

Returndata bombs#

A gas limit on a call bounds what the callee can spend and leaves open what the caller spends afterwards on the callee's output.

Solidity copies the full return data of a low-level call into memory, and it does so even when the code discards the bytes value, as in (bool ok,) = target.call(...). Foundry's return-bomb lint documents this, and the Solidity issue asking the compiler to skip the copy is still open. Memory expansion is priced quadratically, so a callee can spend its capped gas on producing a large output and force the caller to pay about the same amount again to receive it.

In our run, a callee capped at 200,000 gas that returns 300,000 bytes cost the calling function about 431,000 gas for the one call. The same call made in assembly with a zero-length output area cost about 202,000. Reverting with the data instead of returning it gave the same numbers.

The GMX Synthetics finding is this bug in a keeper system. The user's callback was gas-limited, the keeper caught the revert with catch (bytes memory reasonBytes), and the copy of a large revert payload used more gas than the keeper had budgeted, which reverted the batch along with other users' orders. A Code4rena finding against Recall in 2025 has the same root cause in a cross-chain checkpoint.

The fix is to cap the bytes copied. An assembly call with an output size of zero copies nothing, as in the snippet above, and Nomad's ExcessivelySafeCall takes a maximum copy length for callers that need part of the data. Gas estimates for keepers should include the copy as well as the callee's limit.

What try/catch leaves uncaught#

try/catch is often added to make a callback optional, and it covers less than it appears to. The Solidity documentation says that only a failure inside the external call itself is caught. Two common failures happen in the caller and revert the whole function: a call to an address with no code, and return data that does not decode to the declared type. Both reverted in our test with the catch branch never running.

Out-of-gas has a second-order problem. When the callee burns everything it was given, the caller continues with the 64th it kept. If the catch branch and the rest of the function need more than that, the transaction fails anyway, and the callee is the one who decides how much is left.

A catch (bytes memory reason) clause also brings back the returndata copy from the previous section. In the same test the revert bomb cost about 431,000 gas with that clause and about 203,000 with a plain catch { }, which makes the plain form the safer default for untrusted callees.

Unbounded work#

A loop over an array that users can extend has a cost the attacker sets. The bound used to be the block gas limit. Since the Fusaka upgrade on 3 December 2025 there is a tighter one, because EIP-7825 caps a single transaction at 16,777,216 gas (2^24) regardless of the block limit. A batch that was sized against the block limit may no longer fit in one transaction, so every loop whose length depends on usage needs to be rechecked against the new figure.

The Valkyrie finding shows how a loop reaches a hot path. Creating a range was permissionless and appended to an array, and the hook's afterSwap iterated over that array, so enough ranges made every swap on the pool run out of gas. The Uniswap v4 hooks post has more on hook liveness.

The settleRefunds(maxCount) function above is the general remedy. A cursor in storage and a caller-supplied batch size give every call a known upper cost, and any honest party can advance the cursor.

Checklist#

  • For every function that must stay callable, is there a path whose cost and success do not depend on another user's address or contract?
  • Does a failed payment to one user become a recorded debt for that user, with a separate claim function?
  • For each call to untrusted code, are three numbers explicit: the gas forwarded, the bytes copied back, and the gas needed afterwards?
  • Where a relayer or keeper chooses the transaction gas, can a failed inner call be told apart from one that was starved, and is the starved case reverted or retryable?
  • Does every try/catch on an untrusted callee use the plain catch, and has the target address been checked for code?
  • Does every loop have a bound that the protocol sets, with a cursor for the remainder, and does the worst case fit in 16.7M gas?
  • Is there an exit for a single user that works when the batch path is stuck?

Sources#