Keeping Etherlink Secure - Ganesha 7.3 Security Disclosures

The Etherlink Ganesha 7.3 kernel upgrade proposal was successfully activated on block 57,776,852 on November 12th. As outlined here, it was an undisclosed kernel proposal mitigating a set of potential liveness vulnerabilities in the Etherlink kernel. The release addresses a family of issues where malformed or adversarial transactions could risk disrupting block production, or where execution costs were not aligned with the work or memory a transaction triggered. Some of these issues were reported through the bug bounty program and others were found through continued internal auditing and testing. We’d like to thank the external security researchers who help us keep Etherlink secure, as well as the bakers who voted in support of our security upgrade proposal.

Issues Addressed

The common theme is denial-of-service resistance and liveness. This is important to address in the kernel, as the delayed inbox can force transactions to be included: a transaction that should be cheaply rejected as invalid must never be able to abort block production or stop the chain. The release also continues the work begun in Etherlink 7.2 of ensuring that every operation whose cost can grow with user-controlled input is bounded, charged before execution, or rejected safely. Below is a list of all issues addressed.

Delayed-inbox validation and liveness

The largest class of fixes concerns invalid delayed transactions that were aborting the block that included them. Each of the following is now rejected safely:

  • Reject EVM transactions that cannot cover value plus gas: The prepay check did not count the transferred value, so a transaction whose sender could not cover its maximum gas fee plus its value could abort the block. (a15a4f1c59)

  • Reject oversized EVM contract creations: A contract creation whose initcode exceeds the EIP-3860 limit is now invalid rather than fatal. (a20625ff2f)

  • Reject EVM transactions below their intrinsic gas: A transaction whose gas limit does not cover its intrinsic gas is now invalid. (29c346234a)

  • Reject EVM transactions below their EIP-7623 calldata floor: A transaction whose gas limit covers its intrinsic gas but not its calldata floor is now invalid. (b28c063a65)

  • Reject malformed EIP-7702 transactions: EIP-7702 transactions with no destination (ffbb397c51), or with an empty authorization list (24e956fcfb), are now invalid rather than fatal.

  • Reject Michelson operation batches whose gas limits overflow: A Michelson operation batch whose declared gas limits sum past u64 is now invalid. (c7d18b6fb4)

  • Reject Michelson amounts above the mutez domain: A Michelson transfer whose amount (17d13ad1c1), or origination whose balance (1f806a3a41) takes more than 64 bits is now invalid, instead of aborting the block or stopping the chain.

Michelson runtime gas and memory accounting

The kernel also addresses some gas and memory accounting issues for Michelson operations:

  • Charge EDIV for its result allocation: EDIV is now charged at least for the memory its quotient and remainder allocate, closing an out-of-memory vector on divisions of large numbers. (62f5d4cf2d)

  • Charge MAP for key comparisons: Interpreting MAP on a map now consumes gas for the per-key comparisons it performs when updating the accumulator. (d5214c1f4e)

  • Charge map rebuilding during big-map traversal: Gas is now consumed for rebuilding maps while extracting their big maps. (026da52e32)

  • Charge the full budget on alias-creation out-of-gas: When the creation of a sender or source alias runs out of gas - in a Michelson call to the EVM through the runtime gateway (%call, %call_evm) (ecc7e28202), or in an EVM call to Michelson (10661a9733) - the whole gas budget is now charged, as it should be for any out-of-gas condition. An EVM alias initialization that runs out of gas is now also reported as such (2a5e18f7c9).

Bounded error output

Converting large numbers to strings requires changing their representation from binary to decimal, which takes quadratic time in the length of the number. This was a possible attack vector that could lead to very slow block application because not enough gas was consumed for these conversions. In Etherlink 7.3, we stop converting large numbers to decimal by introducing the following size limits:

  • In error messages, numbers taking more than 64 bits are replaced by an indication of their length. (96675f86a5, 4308ecd54d, 28cffe03ba)

  • For the string syntax of timestamp literals, a string that is not RFC3339 compliant and is longer than 32 bytes is now rejected. (99898429ac)

  • Micheline nodes displayed in type-checking error messages (0776fb362c) or raised by the FAILWITH instruction (18886ff727) are now displayed with a bounded representation (e67008edbd) which limits numbers to 64 bits and strings to 256 bytes, and displays at most 10 Micheline nodes.

Runtime gateway hardening

A few aspects of cross-runtime calls have also been improved:

  • Charge gateway calldata before decoding: The per-word charge on gateway calldata, and the base cost of callMichelson, callMichelsonView and call, are now charged before the calldata is decoded. A call forwarding too little gas now runs out of gas without decoding its input, whereas it previously decoded the whole payload first. The total charged for a successful call is unchanged. (c522c2e861)

  • Reject user-supplied gateway headers: The gateway’s %call entrypoints no longer accept a non-empty headers array. These headers were never read by either runtime - an empty array behaves exactly as before (1b606083be, 0e39b9ec49)

Internal-operation cap enforcement

A series of fixes close ways for a transaction to exceed the cap on internal operations. The counter is now preserved across frame reverts (ac0f048c8b), reserves entries for receipts (5441cea20e), stays synchronized across gateway calls (3d1b6b41ab), counts re-entrant receipts in the next batch operation (43adffcd24), is checked for gateway callbacks (bd961cac09), and counts replayed internal operations (944981b76d).

Keeping Etherlink Secure

Our thanks go out to the security experts contributing via the Tezos Foundation bug bounty program. If you are a security researcher, we strongly encourage you to look into Etherlink and other Tezos ecosystem projects. Submitting findings through the bug bounty program remains vital for ensuring the ongoing secure evolution of Etherlink alongside Tezos X.

3 Likes