From 57221bd7604457f8cf3e8ed2a90539a5efdecac0 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Tue, 13 Aug 2024 19:25:04 -0700 Subject: [PATCH] discovery: fix bug that can lead to sending invalid chan_ann msgs Initially in lnd, we didn't store the extra TLV data that could be dangling off of gossip messages. This was fixed initially in lnd v0.5 with this PR: https://github.com/lightningnetwork/lnd/pull/1825. Within the PR, we incorrect set the `ExtraOpaqueData` (extra TLV blob) of the `ChannelAnnouncement` to the value stored in `edge`, which is actually our channel update. As 6-ish years ago we didn't yet have anything that used the TLV gossip fields, this went unnoticed. Fast forward to 2024, we shipped an experimental version of inbounbd fees. This starts to store additional data in the `ExtraOpaqueData` field, the TLV for the inbound fee. Initially, everything is valid when the first `ChannelAnnouncement` is sent, but as soon as a user attempts to set an inbound fee policy, we'd incorrectly swap in that new serialized TLV for the _channel announcement_: https://github.com/lightningnetwork/lnd/commit/841e24399c5e4b211c10f0282c7a1bff3ad8372e#diff-1eda595bbebe495bd74a6a0431c46b66cb4e8b53beb311067c010feac2665dcbR2560. Since we're just trying to generate a new `channel_update`, we don't also regenerate the signature for the `channel_announcement` message. As a result, we end up storing a `channel_announcement` with an invalid sig on disk, continuing to broadcast that to peers. --- discovery/gossiper.go | 2 +- docs/release-notes/release-notes-0.18.3.md | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/discovery/gossiper.go b/discovery/gossiper.go index bb0aa652c..0dcd7a6c9 100644 --- a/discovery/gossiper.go +++ b/discovery/gossiper.go @@ -2232,7 +2232,7 @@ func (d *AuthenticatedGossiper) updateChannel(info *models.ChannelEdgeInfo, BitcoinKey1: info.BitcoinKey1Bytes, Features: lnwire.NewRawFeatureVector(), BitcoinKey2: info.BitcoinKey2Bytes, - ExtraOpaqueData: edge.ExtraOpaqueData, + ExtraOpaqueData: info.ExtraOpaqueData, } chanAnn.NodeSig1, err = lnwire.NewSigFromECDSARawSignature( info.AuthProof.NodeSig1Bytes, diff --git a/docs/release-notes/release-notes-0.18.3.md b/docs/release-notes/release-notes-0.18.3.md index f5225a211..c7e982b7e 100644 --- a/docs/release-notes/release-notes-0.18.3.md +++ b/docs/release-notes/release-notes-0.18.3.md @@ -64,6 +64,10 @@ commitment when the channel was force closed. cause UpdateAddHTLC message with blinding point fields to not be re-forwarded correctly on restart. +* [A bug has been fixed that could cause invalid channel + announcements](https://github.com/lightningnetwork/lnd/pull/9002) to be + generated if the inbound fee discount is used. + # New Features ## Functional Enhancements ## RPC Additions