AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Low 37 Bitcoin

Fix Unknown NetworkMessage encoding

Public commit record

What the developer wrote

Authored by Mitchell Bagot

58/100 · Thin
Fix Unknown NetworkMessage encoding

The NetworkMessageEncoder and old Encodable implementation for
NetworkMessage make use of the Vec<u8> encoding for the raw payload
data. This introduces a vector length prefix to the start of the
encoding which causes the roundtrip for Unknown NetworkMessage types to
fail. In practice, NetworkMessage will only ever be decoded through the
RawNetworkMessage, where a payload length will be known. As such, this
length prefix is not necessary in the encoding and can be trivially
removed.

Change Unknown NetworkMessage encoding to directly write the vector of
bytes instead of using Vec<u8> encoding logic.
✓ Descriptive subject✓ Provides detailed explanatory context
The short version

What changed, and why it matters

This commit fixes a bug in how custom or unknown Bitcoin peer-to-peer messages were being serialized. Previously, the code accidentally added an extra length number to the front of the raw payload bytes, so if you decoded an unknown message and re-encoded it, the bytes would not match. The fix writes the raw payload bytes directly without the extra length prefix, and adds a test to confirm round-trip encoding works.

Recommended action

Review whether any downstream code relied on the previous prefixed encoding for Unknown messages, and consider adding additional round-trip tests for other NetworkMessage variants. The fix should be included in the next release.

Security signals we found

01

Serialization round-trip failure for Unknown NetworkMessage variants

02

Incorrect length prefix in raw payload encoding

03

Potential for protocol interoperability issues with unknown P2P message types

Risk score

Why this scored 37/100

Our methodology →
Potential impact 8/30
Exploitability 5/25
Stealth signal 6/15
Affected reach 7/15
Confidence 7/10
Evidence quality 4/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.