Skip to content

fix: bounds check the lookup table indexes in gossip (#3508) - #3520

Open
pjfanning wants to merge 1 commit into
apache:1.7.xfrom
pjfanning:gossip17
Open

fix: bounds check the lookup table indexes in gossip (#3508)#3520
pjfanning wants to merge 1 commit into
apache:1.7.xfrom
pjfanning:gossip17

Conversation

@pjfanning

Copy link
Copy Markdown
Member

Motivation

Backport of #3508 to 1.7.x: gossip lookup-table indexes went from the wire straight into
Vector.apply, so an out-of-range index raised IndexOutOfBoundsException — and for a
GossipEnvelope the deferred parse puts that throw inside the cluster daemon rather than
on a deserialization thread.

Modification

Cherry-pick of the #3508 change commit. The only conflict was the import block of
ClusterMessageSerializerSpec (the NotSerializableException import); everything else,
including the new lookup helper, applied clean — the touched .asScala...to(...) lines
are identical on 1.7.x, where the file already imports pekko.util.ccompat.JavaConverters.

Note #3508 is still open against main; if review there changes the fix, this backport
should be updated to match before merging.

Result

Same as #3508: gossip referring to a table entry the sender did not include is reported
as a serialization failure naming the index and the table size.

Tests

  • sbt "++ 2.12.21 cluster/Test/compile" — clean, validating Scala 2.12
  • sbt "cluster/scalafmtCheckAll" — clean
  • Test suites intentionally left to CI per the release-prep flow; the three tamper tests
    from fix: bounds check the lookup table indexes in gossip #3508 are included, covering Gossip, GossipStatus, and the deferred
    GossipEnvelope path

References

Backport of #3508.

Motivation:
Gossip interns addresses, roles, hashes and app versions into tables and
refers to them by index. Every index in gossipFromProto came straight off
the wire into Vector.apply with no range check, so a negative or out of
range one raised IndexOutOfBoundsException instead of a serialization
failure.

For a GossipEnvelope this matters more than usual: gossipEnvelopeFromProto
defers the parse into a thunk, so the throw happens inside ClusterCoreDaemon
when the gossip is read rather than on a deserialization thread.

Modification:
Look the indexes up through a helper that range checks first and reports a
NotSerializableException naming the index and the table size. Every index
gossipToProto writes is in range, so nothing a peer legitimately sends is
affected.

Result:
Gossip that refers to a table entry the sender did not include is reported
as a serialization failure.
@pjfanning pjfanning added this to the 1.7.1 milestone Sep 3, 2026
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.

1 participant