AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
High 76 Bitcoin

Don't panic when a composite sub-handler returns `Ok(None)`

Public commit record

What the developer wrote

Authored by Jeffrey Czyz

73/100 · Adequate
Don't panic when a composite sub-handler returns `Ok(None)`

A handler built with `composite_custom_message_handler!` routes an incoming
message type to the sub-handler whose pattern matches it and assumed the
sub-handler would always decode it. But per the `CustomMessageReader`
contract a sub-handler returns `Ok(None)` for a type it doesn't recognize,
and a sub-handler's pattern -- a range in particular -- can be broader than
the types it actually decodes.

Since the message type comes from peer input, this let a remote peer panic
the message-processing thread with a single custom message whose type falls
in a sub-handler's pattern but isn't decoded by it. Report such a message as
unknown instead, matching how `wire::do_read` handles an undecoded custom
message.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context
The short version

What changed, and why it matters

This commit fixes a bug where a remote peer could crash a Lightning node by sending a specially chosen custom message. The crash happened because a message-routing helper assumed a sub-component would always recognize any message type matching its declared pattern, but sub-components can legitimately decline to decode some types within their pattern. The fix replaces an internal 'this should never happen' crash with a graceful 'unknown message' response.

Recommended action

Treat this as a security fix worth backporting to maintained release branches. Nodes using custom message handlers built with the composite macro should upgrade, as a peer can crash them with a single malformed or reserved custom message type. No immediate on-chain risk is indicated, but denial-of-service against the message-processing thread is plausible.

Security signals we found

01

Remote-triggered panic (denial of service) in message-processing thread

02

Violation of `CustomMessageReader` contract assumption in composite handler

03

Peer-controlled input (`message_type`) used as index/pattern match without graceful fallback

04

Fix aligns behavior with existing `wire::do_read` custom-message handling

Risk score

Why this scored 76/100

Our methodology →
Potential impact 22/30
Exploitability 18/25
Stealth signal 12/15
Affected reach 10/15
Confidence 9/10
Evidence quality 5/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.