#37442 [BC-Insight] Potential Address Collision with Precompile Contract During Contract Deployment

Submitted on Dec 4th 2024 at 20:27:45 UTC by @CertiK for Attackathon | Ethereum Protocol

  • Report ID: #37442

  • Report Type: Blockchain/DLT

  • Report severity: Insight

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

  • Impacts:

    • bug in the respective layer 0/1/2 network code that results in unintended smart contract behavior with no concrete funds at direct risk

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

Description

Brief/Intro

Within the contract deployment in the Erigon, it misses the check that the newly created contract address does not belong to the precompile contract addresses, which leads to the address collision.

Vulnerability Details

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

The function create() is utilized to create a contract via contract deployment transaction, opcode Create and Create2.

https://github.com/erigontech/erigon/blob/v2.61.0-beta1/core/vm/evm.go#L353

However, there is no check to ensure the newly created address passed into the function is not one of the precompile contract addresses. The precompile contract addresses are supposed to be reserved only for the precompile contract.

The newly created address is created either via Create() or Create2():

https://github.com/erigontech/erigon/blob/v2.61.0-beta1/core/vm/evm.go#L474

Though this check does not seem to be specified in the execution specification and it is unlikely to occur in a short term due to the hardness of hash collision, it is necessary to ensure the logic correctness of the execution. Note that the revm (used in Ethereum client Reth) has such check:

https://github.com/bluealloy/revm/blob/v50/crates/revm/src/context/evm_context.rs#L320

Impact Details

In case that the newly created contract address belongs to the precompile contract addresses, the contract will never be functional.

References

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

  • https://github.com/bluealloy/revm/tree/v50

Proof of Concept

Proof of Concept

For simplicity, we modify the code inside the Create() to mimic that the newly created address is 0x08 (a precommplile contract address) and test on the Create() .

Run the following test case to show that the 0x08 address is allowed to be deployed with contract:

The test result shows the contract deployment is successful:

Was this helpful?