channeld: fail the channel instead of crashing if we can't build a commitment
What changed, and why it matters
This update fixes a bug where a part of the Core Lightning node (channeld) would crash and enter an endless crash loop if it couldn't build a commitment transaction, for example due to a splice that would push one side's balance below zero. The fix makes the node fail the channel gracefully instead of crashing. A malicious or buggy peer could potentially trigger this crash repeatedly on reconnection, causing denial of service for that channel.
Apply the patch to prevent channeld crashes and denial-of-service via repeated reconnects. Monitor for follow-up commit that prevents the known splice case from reaching this failure path. Consider adding regression tests for unconstructable commitments during splicing.
Security signals we found
NULL pointer dereference crash in channel commitment construction
Denial-of-service via reconnect crash loop
Splice-related balance underflow leading to unconstructable commitment
Missing return-value check on channel_txs() in two call sites
Crash loop only terminable by unilateral close
Evidence from the diff
The commit adds NULL checks after channel_txs() calls in send_commit_part() and handle_peer_commit_sig() within channeld/channeld.c. Previously, channel_txs() could return NULL when a commitment transaction could not be constructed (e.g., amount_msat_add_sat_s64 fails because a splice amount would make a side’s balance negative). The callers then dereferenced the NULL pointer, causing channeld to crash. Because the same commitment is rebuilt on every reconnect, the daemon would crash again each time, creating a persistent crash loop resolvable only by a unilateral close. The patch now calls peer_failed_err() to fail the channel and report the error instead of dereferencing NULL.
Changed components
channeld/channeld.csend_commit_part()handle_peer_commit_sig()channel_txs() callersInspect captured patch +12 / −0
### channeld/channeld.c
@@ -1299,6 +1299,12 @@ static u8 *send_commit_part(const tal_t *ctx,
remote_index, REMOTE,
splice_amnt, remote_splice_amnt, &local_anchor_outnum,
funding_pubkeys);
+ if (!txs)
+ peer_failed_err(peer->pps, &peer->channel_id,
+ "Could not create commitment %"PRIu64
+ " for funding %s",
+ remote_index,
+ fmt_bitcoin_outpoint(tmpctx, funding));
htlc_sigs =
calc_commitsigs(tmpctx, peer, txs, funding_wscript, htlc_map,
remote_index, remote_per_commit, &commit_sig,
@@ -2215,6 +2221,12 @@ static struct commitsig_info *handle_peer_commit_sig(struct peer *peer,
local_index, LOCAL, splice_amnt,
remote_splice_amnt, &remote_anchor_outnum,
funding_pubkeys);
+ if (!txs)
+ peer_failed_err(peer->pps, &peer->channel_id,
+ "Could not create commitment %"PRIu64
+ " for funding %s",
+ local_index,
+ fmt_bitcoin_outpoint(tmpctx, &outpoint));
/* Set the commit_sig on the commitment tx psbt */
if (!psbt_input_set_signature(txs[0]->psbt, 0,Why this scored 60/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.