Skip to content

Version message parsing rejects valid messages accepted by Bitcoin Core #5730

Description

@erickcestari

Found using differential fuzzing (bitcoinfuzz) that rust-bitcoin rejects 46-byte version messages that Bitcoin Core and btcd would accept it.

rust-bitcoin requires all 9 fields, while Bitcoin Core treats fields after receiver as optional (for pre-protocol-106 compatibility).

Bitcoin Core behavior (net_processing.cpp:3559-3621 https://github.com/bitcoin/bitcoin/blob/1f8f7d477ae0d33bd96f7936889c17bd40805fb9/src/net_processing.cpp#L3604)

// Mandatory: version, services, timestamp, addr_recv (46 bytes)
vRecv >> nVersion >> nServices >> nTime;
vRecv >> addrMe;

// Optional: each checked with !vRecv.empty()
if (!vRecv.empty()) { vRecv.ignore(26); vRecv >> nNonce; }
if (!vRecv.empty()) { vRecv >> strSubVer; }
if (!vRecv.empty()) { vRecv >> starting_height; }
if (!vRecv.empty()) { vRecv >> fRelay; }

Defaults: nonce=1, user_agent="", start_height=-1, relay=true

Should rust-bitcoin match Bitcoin Core's optional field handling, or is the current strictness intentional?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions