From f7daa307dd7b2e994b12f88720ebdabac34eb39d 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 8ba9eefad..134fa7515 100644 --- a/docs/release-notes/release-notes-0.18.3.md +++ b/docs/release-notes/release-notes-0.18.3.md @@ -60,6 +60,10 @@ commitment when the channel was force closed. * We'll now always send [channel updates to our remote peer for open channels](https://github.com/lightningnetwork/lnd/pull/8963). +* [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