eth/fetcher: add metadata validation in tx announcement - #33378
Conversation
| t.Fatalf("peering failed: %v", err) | ||
| } | ||
|
|
||
| ann := eth.NewPooledTransactionHashesPacket{Types: []byte{0x09}, Sizes: []uint32{uint32(tx.Size())}, Hashes: []common.Hash{tx.Hash()}} |
There was a problem hiding this comment.
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 …
There was a problem hiding this comment.
Probably a unit test in the eth/tx_fetcher
There was a problem hiding this comment.
I moved it there. It does not fully test the behavior, but I guess it is acceptable
| t.Fatalf("peering failed: %v", err) | ||
| } | ||
|
|
||
| ann := eth.NewPooledTransactionHashesPacket{Types: []byte{0x09}, Sizes: []uint32{uint32(tx.Size())}, Hashes: []common.Hash{tx.Hash()}} |
There was a problem hiding this comment.
You can just use random hash and size for announcement. It should be rejected regardless. It's not necessary to build a valid tx
|
|
||
| conn.SetReadDeadline(time.Now().Add(timeout)) | ||
| msg, err := conn.ReadEth() | ||
| if err != nil && !errors.Is(err, os.ErrDeadlineExceeded) { |
There was a problem hiding this comment.
The expectation here is just the timeout right? The peer shouldn't respond us any message?
There was a problem hiding this comment.
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)
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.
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.
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.
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
Regarding the
FilterTypefunction, 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.