#38554 [BC-Low] Incorrect Transaction Fee Check in `SendRawTransaction()`

Submitted on Jan 6th 2025 at 16:02:18 UTC by @CertiK for Attackathon | Ethereum Protocol

  • Report ID: #38554

  • Report Type: Blockchain/DLT

  • Report severity: Low

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

  • Impacts:

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

Description

Brief/Intro

The SendRawTransaction() allows users to submit signed raw transactions to the local Erigon nodes, which contains a transaction fee check to ensure the transaction does not provide too many fees.

However, the transaction fees calculation is incorrect due to incorrect fetch of gas price for the transaction types, DynamicFeeTxType, BlobTxType and SetCodeTxType. Specifically, the gas price fetched from these types of transactions is the Tip instead of the FeeCap. This overlook makes this transaction fees ineffective as the fee cap is normally much larger than the tip.

Vulnerability Details

Affected Codebase: https://github.com/erigontech/erigon/releases/tag/v3.0.0-alpha7

The function SendRawTransaction() is intended to allow users to submit signed raw transactions to Erigon nodes:

https://github.com/erigontech/erigon/blob/v3.0.0-alpha7/turbo/jsonrpc/send_transaction.go#L18

It first decodes the raw transaction and calls the function checkTxFee() to ensure the provided transaction fee does not exceed the pre-configured 1 Ether.

https://github.com/erigontech/erigon/blob/v3.0.0-alpha7/turbo/jsonrpc/send_transaction.go#L75

The issue is that the gas price fetched from the transaction is mistakenly set as the tip in the transaction types, DynamicFeeTxType, BlobTxType and SetCodeTxType. For example, if the transaction if of type DynamicFeeTxType:

https://github.com/erigontech/erigon/blob/34714c0c25cc59587240ae7abc1c2758315254af/core/types/dynamic_fee_tx.go#L43C1-L43C76

The function GetPrice() returns the Tip in the transaction, which should be the FeeCap. In this case, checkTxFee() does not validate the transaction fees correctly, as the Tip in a transaction is much less than the FeeCap.

For example, even though the FeeCap exceeds the limit, the Tip does not. Consequently, the check does not fail.

Impact Details

The incorrect fetch of gas price of transactions makes the transaction fee validation ineffective. For example, a transaction with a transaction fee exceeding the limit does not fail.

References

  • https://github.com/erigontech/erigon/releases/tag/v3.0.0-alpha7

  • https://ethereum.org/en/developers/docs/gas/

Proof of Concept

Proof of Concept

For simplicity, we modified the test function TestSendRawTransaction() in the file: https://github.com/erigontech/erigon/blob/v3.0.0-alpha7/turbo/jsonrpc/send_transaction_test.go#L93

  1. Create a transaction of type DynamicFeeTxType and submit it:

  1. The test result shows that the GetPrice() fetches the Tip instead of the FeeCap.

Was this helpful?