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

lightningd: don't assume peer existrs in peer_connected_serialize.

Public commit record

What the developer wrote

Authored by Rusty Russell

81/100 · Strong
lightningd: don't assume peer existrs in peer_connected_serialize.

It's always true for the first hook invocation, but if there is more
than one plugin, it could vanish between the two! In the default configuration, this can't happen.

This bug has been around since v23.02.

Note: we always tell all the plugins about the peer, even if it's
already gone.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Fixed: lightningd: possible crash when peers disconnected if there was more than one plugin servicing the `peer_connected` hook.
Reported-by: https://github.com/santyr
Fixes: https://github.com/ElementsProject/lightning/issues/8858
✓ 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 crash bug in Core Lightning's lightningd daemon. When a peer disconnects between two plugin hook invocations, the code could try to read from a peer object that no longer exists, causing a use-after-free style crash. The fix copies the needed peer feature data into the hook payload so it remains valid even if the peer disappears. By default this cannot happen because only one plugin handles the hook, but it becomes possible when more than one plugin is registered.

Recommended action

Upgrade to a Core Lightning release containing this commit if you run multiple plugins that service the peer_connected hook. As a workaround, avoid chaining multiple plugins on the peer_connected hook. No immediate remote exploitability is evident, but the crash is a denial-of-service risk for affected node operators.

Security signals we found

01

use-after-free / dangling pointer risk in peer_connected_serialize

02

peer object dereferenced after potential free between plugin hook callbacks

03

crash on peer disconnection with multiple peer_connected hook plugins

04

Changelog-Fixed labels this as a possible crash

Risk score

Why this scored 43/100

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