lightningd: don't abort when a splice RBF reuses a funding txid
What changed, and why it matters
This fix prevents a malicious or misbehaving channel peer from crashing a Core Lightning node by repeatedly proposing the same splice transaction. Before the patch, the node would hit a database primary-key conflict and abort entirely. Now it detects the duplicate funding transaction, fails the splice command, and marks the channel with an internal error instead of crashing.
Apply the patch and backport to supported releases. Monitor channels for unexpected internal errors after splice RBF. Consider adding tests that exercise duplicate-funding-txid splice scenarios.
Security signals we found
Denial-of-service vector: remote peer could crash lightningd via protocol-level RBF splice
Database primary-key violation treated as fatal abort before fix
Changelog explicitly states security-relevant crash fix
No input validation on duplicate funding txid prior to DB insert
Evidence from the diff
In lightningd/channel_control.c, handle_add_inflight now checks channel_inflight_find() for an existing inflight with the same funding txid before calling new_inflight(). If a duplicate is found, it fails the pending splice_command via command_fail() and calls channel_internal_error() rather than allowing the DB layer to abort the process. The root cause is that the channel_funding_inflights table has a primary key on (channel_id, funding_tx_id), so a byte-identical RBF splice transaction triggers a fatal DB constraint violation.
Changed components
lightningd/channel_control.chandle_add_inflight()channel_funding_inflights database tablesplice/RBF protocol handlingInspect captured patch +24 / −0
### lightningd/channel_control.c
@@ -932,6 +932,30 @@ static void handle_add_inflight(struct lightningd *ld,
return;
}
+ /* An RBF that rebuilds a byte-identical splice tx reuses the
+ * funding txid. Inserting a second inflight with the same
+ * (channel_id, funding_tx_id) violates the primary key, and
+ * the DB layer treats that as fatal and aborts the node. A
+ * peer can force it by RBF-ing into a tx we already recorded.
+ * Fail the pending splice command and the channel instead. */
+ if (channel_inflight_find(channel, &outpoint.txid)) {
+ struct splice_command *cc;
+ const char *txid;
+
+ txid = fmt_bitcoin_txid(tmpctx, &outpoint.txid);
+ cc = splice_command_for_chan(ld, channel);
+ if (cc)
+ was_pending(command_fail(cc->cmd, SPLICE_CHANNEL_ERROR,
+ "add_inflight: duplicate inflight"
+ " funding txid %s",
+ txid));
+ channel_internal_error(channel,
+ "add_inflight: duplicate inflight funding"
+ " txid %s",
+ txid);
+ return;
+ }
+
inflight = new_inflight(channel,
remote_funding,
&outpoint,Why this scored 70/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.