announcement_signatures: add more early returns
What changed, and why it matters
This small change tightens validation in Electrum's Lightning Network code. It makes the program return early and skip processing when it receives or is about to send 'announcement signatures' for a channel that isn't public or doesn't yet have a short channel ID. This likely prevents crashes or incorrect behavior caused by processing incomplete/unready channel data, but the diff alone does not show an obvious exploitable vulnerability.
Treat as a hardening/defensive fix. Review related Lightning message handlers for similar missing readiness checks, and consider whether missing short_channel_id could previously trigger exceptions, invalid signatures, or protocol edge cases. No urgent action required unless additional context shows this fixed a reproducible crash or security issue.
Security signals we found
Defensive input validation added to Lightning protocol message handler
Early return prevents processing announcement signatures on non-public or unready channels
Guard added before signature verification and before sending signatures
No explicit vulnerability or exploit mechanism visible in the diff
Evidence from the diff
In electrum/lnpeer.py, two Lightning-related methods now return early if the channel is not public or lacks a short_channel_id. on_announcement_signatures() now validates the channel before computing the channel announcement hash and verifying node/bitcoin signatures. maybe_send_announcement_signatures() adds the same short_channel_id guard to its existing is_public() check. The change is defensive: it avoids running signature verification or sending signatures on channels that are not ready for public announcement.
Changed components
electrum/lnpeer.pyLightning Network peer message handlingannouncement_signatures message processingInspect captured patch +3 / −1
diff --git a/electrum/lnpeer.py b/electrum/lnpeer.py
index a13b29e..ea8779a 100644
--- a/electrum/lnpeer.py
+++ b/electrum/lnpeer.py
@@ -492,6 +492,8 @@ class Peer(Logger, EventListener):
self.orphan_channel_updates.popitem(last=False)
def on_announcement_signatures(self, chan: Channel, payload):
+ if not chan.is_public() or chan.short_channel_id is None:
+ return
h = chan.get_channel_announcement_hash()
node_signature = payload["node_signature"]
bitcoin_signature = payload["bitcoin_signature"]
@@ -1819,7 +1821,7 @@ class Peer(Logger, EventListener):
self.maybe_send_channel_update(chan)
def maybe_send_announcement_signatures(self, chan: Channel, is_reply=False):
- if not chan.is_public():
+ if not chan.is_public() or chan.short_channel_id is None:
return
if chan.sent_announcement_signatures:
return
Why this scored 46/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.