Repository navigation
Correctness fixes for node announcement validation, HTLC limits, funding state release, BOLT text, and gossip cache - #11632
Conversation
🔴 PR Severity: CRITICAL
🔴 Critical (4 files)
🟠 High (1 file)
🟡 Medium (6 files)
🟢 Low (1 file)
AnalysisThis PR is classified CRITICAL because it modifies To override, add a |
|
I found three issues at
|
5335bed to
64e9a99
Compare
In this commit, we reject channel announcements whose node IDs are equal or in descending lexicographical order before doing any signature verification. BOLT 7 requires receivers to ignore these messages, so accepting them allows invalid gossip to enter and propagate through our graph. The regression covers both equal and descending node IDs and verifies that the ordering error takes precedence over signature validation.
64e9a99 to
cff8b97
Compare
ziggie1984
left a comment
There was a problem hiding this comment.
The code changes address the findings from my review, including the startup and invoice compatibility fixes and the reconnect-pruning guard. The local tests, native lint, staticcheck, and GitHub Static Checks passed on this revision.
The release-note fragment check still needs to pass before merge.
saubyk
left a comment
There was a problem hiding this comment.
Thanks for batching these, the fixes look good from a product side. Main asks before merge:
- Release note needs to move to
docs/release-notes/unreleased/11632.mdwith PR links, or the check will fail. - The BOLT 1 text rules match bolts#1341, but lnd would be the first implementation to enforce them. CLN, Eclair and LDK still create and pay invoices with newlines in the description. Can we plan the rollout (release-note warning, or lenient decoding for a release)?
- Local alias handling: a ZWJ emoji in
alias=now stops startup with a misleading "non-utf8" error, and a stored alias may be silently reset to the pubkey. Please make the errors and the release note clear for operators.
In this commit, we reject remote HTLC constraints that cannot produce a valid channel update: a zero in-flight maximum or a minimum above the channel capacity. This prevents accepted channels from getting stuck before their announcement. We also cap our optional minimum HTLC preference at the remote and capacity-derived maximum. Our preference must not turn otherwise usable remote limits into an invalid update. Focused tests cover rejection at the capacity boundary and the announcement parameter clamp.
In this commit, we stop deferring our own announcement_signatures in the evictable, in-memory futureMsgs cache. The funding manager creates our half only after its required confirmation depth and never re-sends it, so caching could permanently lose it on restart or eviction by any peer. Local halves now go straight through the normal pipeline, which durably stores them and reliably delivers them to our counterparty. Remote halves still wait for the configured proof maturity delta. We also charge the future message cache for retained memory instead of a constant 1 per entry. Each message costs its maximum wire body plus 16 bytes per decoded feature bit, so a dense channel announcement can no longer let one peer pin ~0.7 GB. Ordinary messages keep their 1,000-entry bound, oversized entries are refused, and eviction stays LRU. Tests cover local-proof survival across restart/eviction, weighted admission/eviction, and the dense-feature memory bound.
In this commit, we enforce the BOLT 1 text rules on every field the spec types as utf8: node aliases, BOLT 11 descriptions, and BOLT 12 offer descriptions, issuers, and payer notes. A shared ValidBoltText helper rejects invalid UTF-8, control and format characters, private use, surrogates, and the line and paragraph separators while tolerating unassigned code points. The fixed-width V1 alias keeps its trailing NUL padding but rejects embedded NUL; V2 aliases and all invoice and offer fields validate on both read and write so locally constructed messages cannot carry banned characters either. Tests cover each banned category, malformed UTF-8, and valid non-ASCII text.
In this commit, we centralize pending-channel cleanup in cleanupPendingChannel, which closes the local discovery signal, deletes the initial forwarding policy row and deletes the channel opening state row. All three steps are idempotent, so it is safe to call from several failure paths. We invoke it when a confirmed funding transaction fails wallet validation, when the funding timeout fires, and when the funder receives an invalid funding_signed message. The timeout path also resolves the contract so the chain arbitrator stops watching the channel and the peer is pruned from persistent reconnects. The access manager now re-creates a missing peer score from the persisted pending count on a pending close, so an offline peer's pending channel slot is released instead of leaking temporary access until restart. The backup proxy now treats FundingTimeoutEvent as a close so the timed-out channel is removed from the on-disk backup immediately.
Wrap over-length comments and log lines, convert counted loops to integer ranges, use t.Context in tests, add a checked type assertion, insert missing blank lines before returns, and reflow multi-line statements so the native linter reports no findings on this branch.
The funding timeout handler pruned the peer's persistent connection state unconditionally. A peer can have another open or pending channel while one pending channel times out; pruning then dropped reconnect state for a peer we still share a channel with. The brontide Start path guards its prune with an open-channel count check; mirror that by asking the access manager whether the peer has any open or pending channels before pruning.
cff8b97 to
4d94fc6
Compare
saubyk
left a comment
There was a problem hiding this comment.
Thanks for working through all five. The release note now gives operators clear steps for the stricter text rules, and the new errors name the rejected character. LGTM from a product side.
|
Created backport PR for
Please cherry-pick the changes locally and resolve any conflicts. git fetch origin backport-11632-to-v0.21.x-branch
git worktree add --checkout .worktree/backport-11632-to-v0.21.x-branch backport-11632-to-v0.21.x-branch
cd .worktree/backport-11632-to-v0.21.x-branch
git reset --hard HEAD^
git cherry-pick -x 4174c1c07779b2c1c90b89aa7a144a418a5078d5 67d26d85029f9675e5a611e86cf7f283056e88df 710a79e898beb6a4731340ca4ea9573efa7d417e 03d59d5cc0cc7a0cfc4fb742b75d04ae66bcdb3f 979648da2f226d203fe8035a4e88d48e5b14dcca d1ddf7cab1399808f0ddc28486968c82bdf950a4 62e730808c49ee197e826a843e357c44de5b3d18 dc22517552782dae2c6ebe2831e5ba63299c7190 bcafd9e847abaa086a0d8dd058ef3ae8c291a16d c6c09479722f0ba82d299b88728917780da7381c 4d94fc6500360ea5985a22a964e1dd38cfb85e07
git push --force-with-lease |
This PR is a batch of correctness fixes for the Morehouse public issue set. Each fix is in its own commit with a regression test.
Fixes
channel_announcementwithnode_id_1>=node_id_2is accepted #11598:netannnow rejectschannel_announcementmessages whosenode_id_1is not lexicographically beforenode_id_2, as BOLT 7 requires. The check runs before signature validation, so invalid announcements are rejected cheaply.channel_updateand leave channel stuck inchannelReadySent#11608: channels whose remote HTLC constraints cannot produce a validchannel_update(minimum HTLC above capacity, zero max pending amount) are rejected during funding, and our advertised minimum HTLC is capped at the usable maximum.funding_signednow release all pinned state: the local discovery signal, the initial forwarding policy row, the channel opening state row, the chain arbitrator's watch, on-disk backups, and access-manager pending counts. Persistent connection state is only pruned when the peer has no remaining channels.announcement_signatureslost whengossip.announcement-conf > 6#11626: our own local announcement proofs are never deferred into the evictable in-memory future message cache, where a restart would lose them; only remote proofs are deferred. Local proofs go straight to the durable waiting-proof store.Notes
-tags=dev; the scoped custom linter reports no findings on this branch.ValidBoltTextwas independently reviewed against the BOLT 1 reader requirements.