lightningd: another gossip transition corner case.
What changed, and why it matters
This commit fixes a rare internal state-machine error in Core Lightning that could occur when a channel was closing at exactly the same moment it would normally be announced to the network. Previously, the code did not allow the transition from 'unannounced and dying' directly to 'announced and dead,' causing a 'BROKEN' log error. The patch simply adds that missing allowed transition. It is a bug fix for a corner case, not a security vulnerability that an attacker can exploit.
Treat as a routine bug-fix patch. No urgent security action required. Users should upgrade in normal course if affected by the logged BROKEN state transition, but there is no evidence of remote exploitability or funds at risk.
Security signals we found
Fixes an internal state-machine crash/corner-case (BROKEN log)
No external input validation, cryptographic, or authorization change
No memory safety, overflow, or injection pattern
Change is defensive hardening of gossip state transitions
Evidence from the diff
The patch adds one allowed state transition in lightningd/channel_gossip.c: CGOSSIP_CHANNEL_UNANNOUNCED_DYING -> CGOSSIP_CHANNEL_ANNOUNCED_DEAD. This handles the race where a channel reaches the gossip announce depth and its funding output is spent in the same block processing window. Without this transition, the code logs ‘Illegal gossip state transition’ and aborts the state change. The fix is a two-line addition to the allowed_transitions table.
Changed components
lightningd/channel_gossip.cchannel gossip state machineInspect captured patch +2 / −0
diff --git a/lightningd/channel_gossip.c b/lightningd/channel_gossip.c
index d7d5374..d00627a 100644
--- a/lightningd/channel_gossip.c
+++ b/lightningd/channel_gossip.c
@@ -118,6 +118,8 @@ static struct state_transition allowed_transitions[] = {
"Unannounced channel closed onchain." },
{ CGOSSIP_CHANNEL_UNANNOUNCED_DYING, CGOSSIP_CHANNEL_ANNOUNCED_DYING,
"Unannounced closing channel reached announce depth." },
+ { CGOSSIP_CHANNEL_UNANNOUNCED_DYING, CGOSSIP_CHANNEL_ANNOUNCED_DEAD,
+ "Unannounced closing channel reached announce depth and was closed in same block." },
{ CGOSSIP_WAITING_FOR_ANNOUNCE_DEPTH, CGOSSIP_ANNOUNCED,
"Channel fully announced" },
{ CGOSSIP_WAITING_FOR_MATCHING_PEER_SIGS, CGOSSIP_ANNOUNCED,
Why this scored 19/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.