Skip to content

eth/fetcher: add metadata validation in tx announcement - #33378

Merged
rjl493456442 merged 3 commits into
ethereum:masterfrom
healthykim:bs/tx-fetcher-type
Dec 11, 2025
Merged

eth/fetcher: add metadata validation in tx announcement#33378
rjl493456442 merged 3 commits into
ethereum:masterfrom
healthykim:bs/tx-fetcher-type

Conversation

@healthykim

@healthykim healthykim commented Dec 9, 2025

Copy link
Copy Markdown
Contributor

This PR fixes the bug reported in #33365.

The impact of the bug is not catastrophic. After a transaction is ultimately fetched, validation and propagation will be performed based on the fetched body, and any response with a mismatched type is treated as a protocol violation. An attacker could only waste the limited portion of victim’s bandwidth at most.

However, the reasons for submitting this PR are as follows

  1. Fetching a transaction announced with an arbitrary type is a weird behavior.
  2. It aligns with efforts such as EIP-8077 and eth/fetcher: check for tx on chain as well #33119 to make the fetcher smarter and reduce bandwidth waste.

Regarding the FilterType function, it could potentially be implemented by modifying the Filter function's parameteer itself, but I wasn’t sure whether changing that function is acceptable, so I left it as is.

Comment thread cmd/devp2p/internal/ethtest/suite.go Outdated
t.Fatalf("peering failed: %v", err)
}

ann := eth.NewPooledTransactionHashesPacket{Types: []byte{0x09}, Sizes: []uint32{uint32(tx.Size())}, Hashes: []common.Hash{tx.Hash()}}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe type []byte{0xff}?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, however, I’m considering moving this test somewhere else. Since the hive test uses our test suite, we should check the behavior of other clients first. And this case doesn’t seem to be specified in the original proposal. Still thinking about other possible locations …

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably a unit test in the eth/tx_fetcher

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved it there. It does not fully test the behavior, but I guess it is acceptable

Comment thread cmd/devp2p/internal/ethtest/suite.go Outdated
t.Fatalf("peering failed: %v", err)
}

ann := eth.NewPooledTransactionHashesPacket{Types: []byte{0x09}, Sizes: []uint32{uint32(tx.Size())}, Hashes: []common.Hash{tx.Hash()}}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can just use random hash and size for announcement. It should be rejected regardless. It's not necessary to build a valid tx

Comment thread cmd/devp2p/internal/ethtest/suite.go Outdated

conn.SetReadDeadline(time.Now().Add(timeout))
msg, err := conn.ReadEth()
if err != nil && !errors.Is(err, os.ErrDeadlineExceeded) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The expectation here is just the timeout right? The peer shouldn't respond us any message?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but since multiple test cases may have already run before this, NewPooledTransactionHashesPacket and TransactionsPacket can still arrive. The same approach is used in TestNewPooledTxs. (This test has been removed anyway fyi)

@rjl493456442 rjl493456442 added this to the 1.16.8 milestone Dec 11, 2025
@rjl493456442
rjl493456442 merged commit 56d201b into ethereum:master Dec 11, 2025
7 of 8 checks passed
weiihann pushed a commit to weiihann/go-ethereum that referenced this pull request Jan 14, 2026
This PR fixes the bug reported in ethereum#33365.

The impact of the bug is not catastrophic. After a transaction is
ultimately fetched, validation and propagation will be performed based
on the fetched body, and any response with a mismatched type is treated
as a protocol violation. An attacker could only waste the limited
portion of victim’s bandwidth at most.

However, the reasons for submitting this PR are as follows

1. Fetching a transaction announced with an arbitrary type is a weird
behavior.

2. It aligns with efforts such as EIP-8077 and ethereum#33119 to make the
fetcher smarter and reduce bandwidth waste.

Regarding the `FilterType` function, it could potentially be implemented
by modifying the Filter function's parameter itself, but I wasn’t sure
whether changing that function is acceptable, so I left it as is.
weiihann pushed a commit to weiihann/go-ethereum that referenced this pull request Jan 16, 2026
This PR fixes the bug reported in ethereum#33365.

The impact of the bug is not catastrophic. After a transaction is
ultimately fetched, validation and propagation will be performed based
on the fetched body, and any response with a mismatched type is treated
as a protocol violation. An attacker could only waste the limited
portion of victim’s bandwidth at most.

However, the reasons for submitting this PR are as follows

1. Fetching a transaction announced with an arbitrary type is a weird
behavior.

2. It aligns with efforts such as EIP-8077 and ethereum#33119 to make the
fetcher smarter and reduce bandwidth waste.

Regarding the `FilterType` function, it could potentially be implemented
by modifying the Filter function's parameter itself, but I wasn’t sure
whether changing that function is acceptable, so I left it as is.
gballet pushed a commit to BZO95/go-ethereum that referenced this pull request May 21, 2026
This PR fixes the bug reported in ethereum#33365.

The impact of the bug is not catastrophic. After a transaction is
ultimately fetched, validation and propagation will be performed based
on the fetched body, and any response with a mismatched type is treated
as a protocol violation. An attacker could only waste the limited
portion of victim’s bandwidth at most.

However, the reasons for submitting this PR are as follows

1. Fetching a transaction announced with an arbitrary type is a weird
behavior.

2. It aligns with efforts such as EIP-8077 and ethereum#33119 to make the
fetcher smarter and reduce bandwidth waste.

Regarding the `FilterType` function, it could potentially be implemented
by modifying the Filter function's parameter itself, but I wasn’t sure
whether changing that function is acceptable, so I left it as is.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants