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

lightningd: fail sendpay cleanly when the route does not fit the onion

Public commit record

What the developer wrote

Authored by Ken Sedgwick

83/100 · Strong
lightningd: fail sendpay cleanly when the route does not fit the onion

create_onionpacket returns NULL when the route's per-hop payloads
exceed the 1300-byte onion; send_payment passed the packet to
send_onion unchecked, and serialize_onionpacket dereferenced it,
killing lightningd with SIGSEGV. Observed in production on a
25-hop route submitted by a rebalancing plugin.

The sendonion path already checks this call and fails the command;
mirror it, and add a test.

Changelog-Fixed: JSON-RPC: `sendpay` with a route too long to fit the onion packet now fails cleanly instead of crashing lightningd.
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Mentions testing or verification
The short version

What changed, and why it matters

This commit fixes a crash bug in Core Lightning's payment command. When a user or plugin submitted a payment route with too many hops to fit inside the cryptographic 'onion' envelope, the software failed to check whether the onion was actually created and then tried to use a non-existent object, causing the entire lightningd process to crash with a segmentation fault (SIGSEGV). The patch adds a simple missing check so the command now returns a clean error message instead of crashing the node.

Recommended action

Apply the patch and run the included regression test. Review other callers of create_onionpacket() for missing NULL checks. Consider adding an upper-bound validation on route length earlier in sendpay parsing to fail faster with a clearer message.

Security signals we found

01

NULL-pointer dereference leading to daemon crash (SIGSEGV)

02

Missing return-value check on create_onionpacket()

03

Denial-of-service vector: malformed/long route crashes lightningd

04

Crash observed in production on a 25-hop rebalancing-plugin route

05

Existing sendonion path already had correct check, indicating this path was overlooked

Risk score

Why this scored 66/100

Our methodology →
Potential impact 22/30
Exploitability 12/25
Stealth signal 8/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.