Skip to content

[bug]: fixed-width node announcement address decoders accept short reads #11211

Description

@s1ns3nz0

Environment

  • LND version: upstream master at 88959aec3d7a9d11a509714d9bee97c29ee02269 (2026-09-18)
  • Backend version: N/A
  • OS/Distribution: N/A
  • Configuration: N/A; this reproduces in lnwire unit tests

Bug Details & Steps to Reproduce

The IPv4, IPv6, and Tor v3 address TLV decoders use io.Reader.Read for fixed-width fields and do not verify that the requested number of bytes was returned.

A conforming reader may return (n < len(buf), nil). The decoder then interprets the unread zero-filled bytes as part of the address.

Minimal examples:

  • IPv4: 5 bytes supplied for a 6-byte record
  • IPv6: 17 bytes supplied for an 18-byte record
  • Tor v3: tor.V3DecodedLen+1 bytes supplied for a tor.V3DecodedLen+2 record

The existing implementation accepts each input and returns an address.

Expected Behavior

A fixed-width address field should be read completely. Truncated input should return an error.

A reader that legitimately returns data in small fragments should still decode successfully when the complete record is available.

Proposed Fix

Replace the six fixed-width Read calls in lnwire/node_announcement_2.go with io.ReadFull.

The proposed change is limited to decoder correctness. It does not change the TLV format or reject any complete valid record.

Tests

Regression coverage includes:

  • truncated IPv4, IPv6, and Tor v3 records are rejected;
  • two complete addresses decode successfully;
  • complete records decode through iotest.OneByteReader;
  • focused fuzz targets continue to pass.

This is reported as a parser correctness issue. I have not confirmed a network-wide gossip impact or a separate live security exploit.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions