Skip to content

cl/sentinel: fix panic on short attnets ENR entry#20492

Merged
AskAlexSharov merged 1 commit intomainfrom
alex/sentinel_bitvec_panic_35
Apr 11, 2026
Merged

cl/sentinel: fix panic on short attnets ENR entry#20492
AskAlexSharov merged 1 commit intomainfrom
alex/sentinel_bitvec_panic_35

Conversation

@AskAlexSharov
Copy link
Copy Markdown
Collaborator

Summary

Fixes a panic seen in the wild:

panic: runtime error: index out of range [4] with length 1
  cl/sentinel.(*Sentinel).findPeersForSubnets.func1
        cl/sentinel/discovery.go:80

A malformed/short attnets ENR entry decodes into a bitfield.Bitvector64 shorter than the expected 8 bytes, so indexing peerSubnets[subnetIdx/8] goes out of range when subnetIdx >= 8.

Adds a len(peerSubnets) == 8 guard at all three call sites in cl/sentinel/discovery.go (findPeersForSubnets filter, post-connect coverage update, and onConnection underserved-subnet check).

A malformed attnets ENR can decode into a Bitvector64 shorter than
8 bytes, causing 'index out of range' panic in findPeersForSubnets
when indexing peerSubnets[subnetIdx/8]. Reject such nodes.
@AskAlexSharov AskAlexSharov enabled auto-merge April 11, 2026 06:12
AskAlexSharov added a commit that referenced this pull request Apr 11, 2026
Cherry-pick of #20492 to release/3.4.

## Summary
Fixes a panic seen in the wild:

```
panic: runtime error: index out of range [4] with length 1
  cl/sentinel.(*Sentinel).findPeersForSubnets.func1
        cl/sentinel/discovery.go:80
```

A malformed/short `attnets` ENR entry decodes into a
`bitfield.Bitvector64` shorter than the expected 8 bytes, so indexing
`peerSubnets[subnetIdx/8]` goes out of range when `subnetIdx >= 8`.

Adds a `len(peerSubnets) == 8` guard at all three call sites in
`cl/sentinel/discovery.go`.
@AskAlexSharov AskAlexSharov added this pull request to the merge queue Apr 11, 2026
Merged via the queue into main with commit 933f986 Apr 11, 2026
35 checks passed
@AskAlexSharov AskAlexSharov deleted the alex/sentinel_bitvec_panic_35 branch April 11, 2026 07:30
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