#38557 [BC-Insight] Function `IsPush()` Misses Opcode PUSH0

Submitted on Jan 6th 2025 at 19:51:52 UTC by @CertiK for Attackathon | Ethereum Protocol

  • Report ID: #38557

  • Report Type: Blockchain/DLT

  • Report severity: Insight

  • Target: https://github.com/ledgerwatch/erigon

  • Impacts:

    • (Specifications) A bug in specifications with no direct impact on client implementations

Description

Brief/Intro

The opcode PUSH0 is introduced in EIP-3855 (https://eips.ethereum.org/EIPS/eip-3855 ) that pushes the constant value 0 onto the stack.

In Erigon (https://github.com/erigontech/erigon ), the function IsPush() is used to check if an opcode is a push opcode, which does not include the PUSH0 opcode. In the current implementation, this function IsPush() is mostly utilized in the execution tracer and external tools, such asm and goja. Missing the opcode PUSH0 would mess up the trace generated in the upstream applications.

Vulnerability Details

Affected Codebase: https://github.com/erigontech/erigon/tree/v2.61.0

The function IsPush() is intended to check if an opcode is a push opcode, that is, the opcodes from PUSH0 to PUSH32:

https://github.com/erigontech/erigon/blob/v2.61.0/core/vm/opcodes.go#L27

However, it misses the PUSH0 opcode introduced in the EIP-3855 (https://eips.ethereum.org/EIPS/eip-3855 ). This function IsPush() is currently utilized in the upstream execution tracer and external application. For example, the CaptureState() in

https://github.com/erigontech/erigon/blob/v2.61.0/cmd/state/commands/opcode_tracer.go#L355

Though it does not affect the state transition of the Ethereum, the execution trace and other external applications dependent on it would be incorrect.

Impact Details

The function IsPush() is only utilized in transaction execution trace and other external applications and does not impact the state transition of Ethereum at this moment, it would mess up the trace and produce incorrect execution trace for the upstream application.

References

  • https://github.com/erigontech/erigon/tree/v2.61.0

  • https://eips.ethereum.org/EIPS/eip-3855

Proof of Concept

Proof of Concept

For simplicity, we create the following simple test cases:

  1. Check if PUSH0, PUSH1 and PUSH32 are push opcodes:

  1. The test result shows that the PUSH0 is not push opcode:

Was this helpful?