Skip to content

Conversation

antonis19
Copy link
Contributor

This PR handles overflow and underflow attack vectors for the GetBlockHeaders request via specially crafted Skip value.

The issue was first brought to attention in this issue: erigontech/erigon#13931

next := current + query.Skip + 1
if next <= current { // check for overflow
infos, _ := json.MarshalIndent(peer.Peer.Info(), "", " ")
peer.Log().Warn("GetBlockHeaders skip overflow attack", "current", current, "skip", query.Skip, "next", next, "attacker", infos)
Copy link
Member

Choose a reason for hiding this comment

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

The same, our implementation is resistant with the invalid devp2p message

If overflow happens and the corresponding header is not found, the loop will be terminated very soon;
If overflow happens and the corresponding header exists, the loop continue but the maximum number of headers can be served is still capped.

Copy link
Member

Choose a reason for hiding this comment

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

It makes no sense to keep emitting warning logs for the invalid devp2p message, as they are allowed by protocol.

The correct way is to ensure these invalid messages are sanitized and handled properly, without the ability to crash the node.

@antonis19
Copy link
Contributor Author

@rjl493456442 I removed the log statements. Can you review again?

@rjl493456442
Copy link
Member

rjl493456442 commented Apr 1, 2025

I don’t think applying this patch is necessary. As mentioned earlier, it’s up to the requester to determine which part of the chain segment they want to request. If the requested data is available, it will be aggregated into the response.

Additionally, the response size and serving time are already protected by certain limits. It's not possible for attackers to bypass these constrains and result in the heavy resource abusing.

EDIT: discussed with team and we decide we go with this patch.

@rjl493456442 rjl493456442 self-assigned this Apr 1, 2025
@rjl493456442 rjl493456442 added this to the 1.15.8 milestone Apr 3, 2025
@rjl493456442 rjl493456442 merged commit 22c0605 into ethereum:master Apr 3, 2025
3 of 4 checks passed
sivaratrisrinivas pushed a commit to sivaratrisrinivas/go-ethereum that referenced this pull request Apr 21, 2025
sduchesneau pushed a commit to streamingfast/go-ethereum that referenced this pull request May 22, 2025
jakub-freebit pushed a commit to fblch/go-ethereum that referenced this pull request Jul 3, 2025
jakub-freebit pushed a commit to fblch/go-ethereum that referenced this pull request Jul 23, 2025
howjmay pushed a commit to iotaledger/go-ethereum that referenced this pull request Aug 27, 2025
jakub-freebit pushed a commit to fblch/go-ethereum that referenced this pull request Sep 3, 2025
jakub-freebit pushed a commit to fblch/go-ethereum that referenced this pull request Sep 4, 2025
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