Skip to content

[bug] channel announcement signatures must cover the tlv stream #9000

@t-bast

Description

@t-bast

I've been noticing that our node receives a lot of gossip data that has invalid signatures.
This happens for node announcements, channel announcements and channel updates.

I've been able to track the reason behind the channel announcement issue: those channel announcements contain a TLV field (with tag 55555) and the signature doesn't cover that TLV field (it should!). Here is one example from mainnet:

// Encoded channel announcement:
01009fa1d5b5ee517104c5eae0c9962b513e89d6de5dad09366ff9b4f21f3299d4485dc54f1fa8add3272a9b61cc9c63619125c1b9500314a9add2d15cfcc6549d8a51e486f4e5f08f56a1b4000044dcdd920476c6a49d843057c2885e380e3d85ca33b734ba285bcf8290e15ded660095eb1f53b124ac73fffd3023a656b5e120fc356016a694fbb559e86da9e22f7ecfd1894df1618ad0289b7b6b44d6ce11334511539b07373b333527bd71605f11a7b24b8576b0999c995ea4edbe245c1d140c360961128f3d567be9959f0aa024d280d80942153b0846ff24c17cb9b93d0dd54e53dbc2a66f8158fa063ca110ca0f4c46ada5207b48d047604309372993139300006fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d61900000000000c8d520009a90001023e24602891c28a7872ea1ad5c1bb41abe4206ae1599bb981e3278a121e7895d603ad0188fd1c10f9b2f41349a7433072c3a350ad719bd1a5f3b8da4808f97b699603cde7e22d13a1b5b7625766240a38465324dee3eacda3a693866af37e68b8c7b502e92ec7ab9b3fbdd6a88ff547cf2899d4726297eea357e6219c7a42e5296095b4fdd903080000000000000000

val chanAnn = ChannelAnnouncement(
    nodeSignature1 = "9fa1d5b5ee517104c5eae0c9962b513e89d6de5dad09366ff9b4f21f3299d4485dc54f1fa8add3272a9b61cc9c63619125c1b9500314a9add2d15cfcc6549d8a",
    nodeSignature2 = "51e486f4e5f08f56a1b4000044dcdd920476c6a49d843057c2885e380e3d85ca33b734ba285bcf8290e15ded660095eb1f53b124ac73fffd3023a656b5e120fc",
    bitcoinSignature1 = "356016a694fbb559e86da9e22f7ecfd1894df1618ad0289b7b6b44d6ce11334511539b07373b333527bd71605f11a7b24b8576b0999c995ea4edbe245c1d140c",
    bitcoinSignature2 = "360961128f3d567be9959f0aa024d280d80942153b0846ff24c17cb9b93d0dd54e53dbc2a66f8158fa063ca110ca0f4c46ada5207b48d0476043093729931393",
    features = Features.empty,
    chainHash = "6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000",
    shortChannelId = "822610x2473x1",
    nodeId1 = "023e24602891c28a7872ea1ad5c1bb41abe4206ae1599bb981e3278a121e7895d6",
    nodeId2 = "03ad0188fd1c10f9b2f41349a7433072c3a350ad719bd1a5f3b8da4808f97b6996",
    bitcoinKey1 = "03cde7e22d13a1b5b7625766240a38465324dee3eacda3a693866af37e68b8c7b5",
    bitcoinKey2 = "02e92ec7ab9b3fbdd6a88ff547cf2899d4726297eea357e6219c7a42e5296095b4",
    tlvStream = TlvStream(Set.empty[ChannelAnnouncementTlv], Set(GenericTlv(tag = 55555, value = 0x0000000000000000)))
)

The signatures in this channel announcement don't cover the full channel announcement, as they don't sign the TLV stream. If you remove the TLV stream data, then the signatures are valid.

For node announcements, I'm not sure what the issue is. The following node announcement for example was relayed to our node and has an invalid signature:

// Encoded node announcement:
01012dde9e1f6fc92bc32286434ea0387898b87614608985dba49c8595d07ce4f7fc1549eb972f72eb2557c784dcb06e3b4cadc9aac12a5b62fc3991e0d54fae5ec600062000080aa2a266b0815303f27a6b17368dda34e01d183411d8350dfa8436a85a01cf325d52ebca1f13905800000000000000000000000000000000000000000000000000000000000000000000000000

NodeAnnouncement(
    signature = "2dde9e1f6fc92bc32286434ea0387898b87614608985dba49c8595d07ce4f7fc1549eb972f72eb2557c784dcb06e3b4cadc9aac12a5b62fc3991e0d54fae5ec6",
    features = Features(
      Features.Wumbo -> FeatureSupport.Optional,
      Features.UpfrontShutdownScript -> FeatureSupport.Optional,
      Features.DataLossProtect -> FeatureSupport.Optional,
      Features.VariableLengthOnion -> FeatureSupport.Optional,
      Features.StaticRemoteKey -> FeatureSupport.Optional,
      Features.PaymentSecret -> FeatureSupport.Optional,
      Features.ShutdownAnySegwit -> FeatureSupport.Optional,
      Features.ChannelType -> FeatureSupport.Optional,
      Features.BasicMultiPartPayment -> FeatureSupport.Optional,
      Features.ChannelRangeQueries -> FeatureSupport.Optional,
    ),
    timestamp = 1722843475 unixsec,
    nodeId = "03f27a6b17368dda34e01d183411d8350dfa8436a85a01cf325d52ebca1f139058",
    color = Color(0, 0, 0),
    alias = "",
    addresses = List(),
    tlvStream = TlvStream.empty
)

I'd like to know if lnd agrees that the signature is incorrect: if that's the case, why is lnd still relaying that invalid node announcement?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions