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

lightningd: handle large numbers of command outputs gracefully.

Public commit record

What the developer wrote

Authored by Rusty Russell

83/100 · Strong
lightningd: handle large numbers of command outputs gracefully.

Profiling shows us spending all our time in tal_arr_remove when dealing
with a giant number of output streams. This applies both for RPC output
and plugin output.

Use linked list instead.

tests/test_coinmoves.py::test_generate_coinmoves (2,000,000, sqlite3):
Time (from start to end of l2 node): 239 seconds **WAS 518**
Worst latency: 56.9 seconds **WAS 353**

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
✓ 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 change is a performance fix, not a direct security patch. It swaps a slow array for a linked list when handling large numbers of output streams for RPC responses and plugin messages. The old array approach caused severe slowdowns—up to hundreds of seconds of delay in extreme cases—which could be abused to make the node sluggish or unresponsive. The fix removes that bottleneck, making large-output operations finish much faster and reducing the chance of a denial-of-service via resource exhaustion.

Recommended action

Treat as a hardening/performance improvement rather than a critical vulnerability. Backport to supported branches if large RPC or plugin outputs are expected, because the prior behavior could be leveraged for denial of service. Monitor for any follow-up commits that add explicit limits or rate controls on output stream creation.

Security signals we found

01

Performance bottleneck in output stream management could be triggered by large RPC/plugin responses, leading to denial of service via resource exhaustion or severe latency.

02

Fix removes O(n^2) behavior when many json_stream objects are queued and drained in order.

03

No explicit bounds or rate-limiting added; the change only improves data structure efficiency.

04

No memory safety fixes, input validation changes, or cryptographic modifications present.

Risk score

Why this scored 27/100

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