lightningd: fix crash on mutual close of an unconfirmed dual-funded channel
What changed, and why it matters
This update fixes a bug where a specific type of Lightning channel close could crash the node. It only happens when both parties cooperatively close a dual-funded channel that has not yet been confirmed and has gone through a funding bump (RBF). The crash is due to the software looking in the wrong place for a needed public key. The fix makes it use the correct copy of that key.
Apply the patch. It is a targeted, low-risk fix. Node operators running dual-funded channels with RBF should upgrade to avoid crashes during cooperative close of unconfirmed channels.
Security signals we found
NULL pointer dereference leading to daemon crash (denial of service)
Crash occurs in cooperative-close path for unconfirmed dual-funded/RBF channels
Fix uses canonical channel funding key instead of splice-only field
Evidence from the diff
In drop_to_chain(), when handling a cooperative close of an unconfirmed dual-funded channel with multiple inflights (e.g., after RBF), the code builds a 2-of-2 redeem script for each non-closed inflight to watch for later confirmation. It previously used inflight->funding->splice_remote_funding, which is only populated for splices and is NULL for RBF candidates. This caused a NULL pointer dereference inside pubkey_cmp() and a fatal SIGABRT. The patch falls back to channel->channel_info.remote_fundingkey when splice_remote_funding is NULL, since RBF does not change funding keys.
Changed components
lightningd/peer_control.cdrop_to_chain()dual-funded channel cooperative closeRBF inflight handlingInspect captured patch +9 / −3
### lightningd/peer_control.c
@@ -523,13 +523,19 @@ void drop_to_chain(struct lightningd *ld, struct channel *channel,
* force close. */
if (cooperative) {
list_for_each(&channel->inflights, inflight, list) {
+ const struct pubkey *remote_funding;
+ const u8 *funding_wscript;
+
if (bitcoin_outpoint_eq(&inflight->funding->outpoint,
&channel->funding)) {
continue;
}
- const u8 *funding_wscript = bitcoin_redeem_2of2(tmpctx,
- &channel->local_funding_pubkey,
- inflight->funding->splice_remote_funding);
+ remote_funding = inflight->funding->splice_remote_funding;
+ if (!remote_funding)
+ remote_funding = &channel->channel_info.remote_fundingkey;
+ funding_wscript = bitcoin_redeem_2of2(tmpctx,
+ &channel->local_funding_pubkey,
+ remote_funding);
watch_scriptpubkey(inflight, ld->topology,
take(scriptpubkey_p2wsh(NULL, funding_wscript)),
&inflight->funding->outpoint,Why this scored 51/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.