Reproduced Exploit

Aligned Layer: public signature check lets anyone zero a prepaid balance

createNewTask is onlyBatcher and computes feePerProof from gas. checkMerkleRootAndVerifySignatures is public and takes feePerProof from the caller. The user signs keccak256(abi.encodePacked(leaf, nonce)), which does not include the fee. A permissionless caller replays that signature with feePerProo…

Aug 2024•Ethereum•untagged•3 min read

Loss

500 ETH prepaid balance zeroed (user balance 500 ether → 0). The ether stays in the payment contract and is n…

Chain

Ethereum

Category

untagged

Date

Aug 2024

Source

AuditVault

EVM Playground

Source-level debugger — step opcodes and Solidity in sync

evm-hack-analyzer

The attack replays in your browser. Step through it by Solidity line or by opcode.

The attack is replayed in an in-browser EVM preloaded with the exact dumped fork state. The execution tree shows every call; step by Solidity line or by opcode across all depths — source, Stack, Memory, Storage, Balances (native / ERC-20 / NFT), Transient storage and Return value stay in sync. Click a tree node, opcode, or source line to jump. Query opens a search over the trace: previous and next writes, balance changes and calls, breakpoints, and a diff of everything that changed between two steps. No backend, no live RPC.

Loading fork state…

Source & credit. Reproduction of a public audit finding curated by AuditVault — the original finding: 38363-public-visibility-on-checkmerklerootandverifysignatures-allo. Standalone Foundry PoC and full write-up: 38363-public-visibility-on-checkmerklerootandverifysignatures-allo_exp in the evm-hack-registry mirror.


Vulnerability classes: vuln/access-control · vuln/auth · vuln/input-validation · vuln/dos

Key info#

FieldValue
Loss500 ETH prepaid balance zeroed (user balance 500 ether → 0). The ether stays in the payment contract and is no longer withdrawable
Vulnerable contractBatcherPaymentService.checkMerkleRootAndVerifySignatures
Attacker EOA0x1111111111111111111111111111111111111111
Attack contractExploit
Attack txExploit.run()
Chain / block / dateEthereum model · block 0 · 2024-08
Compilersolc 0.8.27, cancun, via IR
Bug classpublic balance debit with an unsigned fee

TL;DR#

createNewTask is onlyBatcher and computes feePerProof from gas. checkMerkleRootAndVerifySignatures is public and takes feePerProof from the caller. The user signs keccak256(abi.encodePacked(leaf, nonce)), which does not include the fee. A permissionless caller replays that signature with feePerProof equal to the 500 ETH prepaid balance. The balance becomes 0, the nonce becomes 1, and the batcher's later task reverts.

The vulnerable code#

SOLIDITY
function checkMerkleRootAndVerifySignatures(
    bytes32[] calldata leaves,
    bytes32 batchMerkleRoot,
    SignatureData[] calldata signatures,
    uint256 feePerProof
) public virtual { // @> VULN: no onlyBatcher; feePerProof is a free argument
    _checkMerkleRootAndVerifySignatures(leaves, batchMerkleRoot, signatures, feePerProof);
}

bytes32 noncedHash = keccak256(abi.encodePacked(hash, signatureData.nonce));
require(user_data.nonce == signatureData.nonce, "Invalid Nonce");
user_data.nonce++;
user_data.balance -= feePerProof; // @> VULN: caller-chosen feePerProof drains the signer

The production fix made the function private (Aligned Layer PR 801). The control contract keeps the same body behind onlyBatcher. An authorized 1 ETH fee leaves 499 ETH. It does not hit 0.

Root cause#

Signature verification and the balance debit live in a public function. The signed payload does not bind feePerProof, and nothing checks msg.sender.

Preconditions#

  • A user has a prepaid balance (here, 500 ETH).
  • The caller has a valid signature over (leaf, nonce) for that user. That signature is what the batcher would submit in createNewTask.

Attack walkthrough#

  1. Recover the signer from keccak256(leaf, nonce). The fee is not in the hash.
  2. Credit that signer 500 ETH.
  3. Call the public check with feePerProof = 500 ETH and the same signature.
  4. The nonce increments and the balance becomes 0. The 500 ETH remains in the contract.
  5. Reusing the signature reverts with Invalid Nonce.

Diagrams#

flowchart TD A["Signer prepaid 500 ETH"] --> B["Signature is keccak256 of leaf and nonce"] B --> C["Public checkMerkleRootAndVerifySignatures feePerProof = 500 ETH"] C --> D["VULN: no onlyBatcher and the fee is not signed"] D --> E["Nonce becomes 1 and balance becomes 0"] E --> F["500 ETH stays in the contract and the batcher task reverts"]

Impact#

The signer loses the entire prepaid balance. In this PoC that is 500 ETH: user_balances is 0 and the contract still holds 500 ETH. The burned nonce also blocks the legitimate createNewTask that carried the same signature.

Remediation#

Make checkMerkleRootAndVerifySignatures private, as in PR 801, and only call it from onlyBatcher createNewTask. Bind feePerProof into the signed hash.

How to reproduce#

BASH
cd 38363-public-visibility-on-checkmerklerootandverifysignatures-allo_exp
forge test -vv

Sources#


Sources & further analysis#

Reproductions & code

Alerts & third-party analyses

  • Web3Sec X hacked database: search.
  • Rekt leaderboard: search.
  • Solodit incident search: search.

These dashboards index community alerts tweets, post-mortems, and independent write-ups. Reach them through the protocol name above to cross-check this reproduction against other analyses.