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

Reject onion per-hop lengths exceeding packet (#3395)

Public commit record

What the developer wrote

Authored by pm47

81/100 · Strong
Reject onion per-hop lengths exceeding packet (#3395)

The sender knows the shared secret, so it can build an onion with a valid
hmac whose per-hop payload length is larger than the packet. We didn't
check that length: we either decoded a garbage next packet, or threw when
extracting the hmac, outside of the Try. This exception escaped the relayer
(which was then resumed, so the HTLC was never failed) and would prevent
PostRestartHtlcCleaner from initializing on the next restart.

We now return InvalidOnionVersion, as we already do for an invalid length.

Closes https://github.com/project-loupe/audit-eclair/issues/104
Closes https://github.com/project-loupe/audit-eclair/issues/215
Closes https://github.com/project-loupe/audit-eclair/issues/140

Reported-By: [project-loupe](https://github.com/project-loupe)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Links an issue, advisory, or supporting reference
The short version

What changed, and why it matters

This commit fixes a bug in how Eclair processes encrypted routing instructions (onion packets) for Lightning payments. A malicious sender could craft a packet that claimed its inner payload was longer than the packet itself. The old code either produced garbage or crashed outside of the expected error-handling path. That crash could escape the payment relayer, meaning the node would not properly fail the affected payment, and it could also break startup recovery code after a restart. The fix adds a length check and returns a standard invalid-onion error instead of crashing.

Recommended action

Treat this as a security fix and include it in the next maintenance release. Nodes should upgrade promptly because the bug is remotely triggerable by any peer that can send an HTLC with a crafted onion packet, and it can impair both live relaying and restart recovery. Review other variable-length parsing paths in Sphinx for similar missing upper-bound checks.

Security signals we found

01

Unchecked length field from attacker-controlled onion packet used for slicing

02

Exception thrown outside Try block, bypassing expected error handling

03

Relayer crash could leave HTLC un-failed

04

PostRestartHtlcCleaner initialization failure on next restart

05

Fix maps malformed input to standard InvalidOnionVersion failure

Risk score

Why this scored 74/100

Our methodology →
Potential impact 22/30
Exploitability 16/25
Stealth signal 12/15
Affected reach 12/15
Confidence 8/10
Evidence quality 4/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.