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

lightningd: fix crash and busy-loop on invoice with huge expiry

Public commit record

What the developer wrote

Authored by Amperstrand

73/100 · Adequate
lightningd: fix crash and busy-loop on invoice with huge expiry

invoice's `expiry` parameter is an unclamped param_u64, and far-future
values break the daemon in two different ways:

- expiry >= 2^60 needs more bits than push_varlen_field() can encode in
the bolt11 `x` field, so bolt11_encode() aborts the whole daemon
(FATAL SIGNAL 6).

- far below that (anywhere past ~584k years), the invoice expiration
timer's nanosecond-grain u64 counter overflows: install_expiration_timer()
arms a timer that reads as already due, trigger_expiration() finds
nothing expired, re-arms, and the daemon busy-loops at 100% CPU with
the RPC reply left racing the storm.

Refuse at the parameter stage instead: expiry >= 2^32 seconds (~136
years) returns JSONRPC2_INVALID_PARAMS, keeping a wide margin under both
limits. 2^32 - 1 still works.

Changelog-Fixed: lightningd: fix crash (`FATAL SIGNAL 6`) and a 100% CPU busy-loop when calling `invoice` with an `expiry` too far in the future (now refused above 2^32 seconds).
(cherry picked from commit 009caeb30f216df22f33fcc607d1c21ead859447)
✓ 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 in Core Lightning's invoice creation command. If a user requested an invoice that expired extremely far in the future (more than about 136 years), the software would either crash the entire payment daemon or get stuck using 100% CPU. The fix simply rejects such large expiry values early, returning a normal error instead of crashing or looping.

Recommended action

Apply this patch promptly. It is a clean input-validation fix with no functional changes for normal expiry values. Review other u64 RPC parameters that are converted to nanoseconds or varint fields for similar overflow issues.

Security signals we found

01

Denial-of-service via daemon crash (SIGABRT) from oversized bolt11 x-field encoding

02

Denial-of-service via 100% CPU busy-loop from u64 nanosecond overflow in expiration timer

03

Input validation gap on RPC parameter leading to resource exhaustion

04

Regression test added for the boundary condition

Risk score

Why this scored 74/100

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