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

lightningd: avoid race when runtime-added plugins register hooks.

Public commit record

What the developer wrote

Authored by Rusty Russell

73/100 · Adequate
lightningd: avoid race when runtime-added plugins register hooks.

If we add a new hook, not at the end, while hooks are getting called,
then iteration could be messed up (e.g. calling a plugin twice, or
skipping one).

The simplest thing is to defer updates until nobody is calling the
hook. In theory this could livelock, in practice it won't.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context
The short version

What changed, and why it matters

This patch fixes a race condition in Core Lightning's plugin hook system. If a plugin was added or removed while a hook (like the one that decides whether to accept a payment) was actively being called, the internal list of plugins could be modified mid-iteration. That could cause a plugin to be called twice or skipped entirely, potentially leading to incorrect payment handling or other unexpected behavior. The fix defers updates to the hook list until all current callers are finished.

Recommended action

Treat as a stability and potential security fix. Review whether the deferred-update logic correctly handles all destruction and re-registration edge cases, and consider backporting to maintained branches. No immediate CVE is indicated by the commit message, but the bug could affect payment correctness.

Security signals we found

01

Race condition in dynamic plugin hook registration

02

Possible double-call or skip of hook callbacks

03

Affects htlc_accepted and other plugin hooks

04

Reference-counted deferred update pattern introduced

05

Regression test added to demonstrate deferred update

Risk score

Why this scored 61/100

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