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

Hold peer lock when pushing to decode_update_adds

Public commit record

What the developer wrote

Authored by Valentine Wallace

80/100 · Strong
Hold peer lock when pushing to decode_update_adds

This avoids race conditions where we're unable to properly update an HTLC's
state because we need to update its state in the ChannelManager, but the HTLC
is stuck in transit from the Channel to
ChannelManager::decode_update_add_htlcs. Now the HTLC will atomically go from
the Channel to the ChannelManager decode queue under the same lock.
✓ Descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Explains rationale or failure mode
The short version

What changed, and why it matters

This change fixes a timing issue in how the Lightning node hands off payment packets (HTLCs) between two internal components. Previously, an HTLC could be in an in-between state where one part of the code thought it had been forwarded while another part had not yet processed it, potentially leading to inconsistent bookkeeping. The fix moves the handoff so it happens while the same lock is held, making the transition atomic.

Recommended action

Review the lock ordering around peer_state, decode_update_add_htlcs, and claimable_payments/pending_outbound_payments to ensure no deadlock is introduced. Add regression tests that exercise concurrent monitor update completion and HTLC forwarding. Consider whether the serialization lock reordering needs documentation.

Security signals we found

01

Race condition in HTLC state handoff between Channel and ChannelManager

02

Atomicity fix for decode_update_add_htlcs queueing under peer lock

03

Potential inconsistent HTLC state update during monitor update completion

04

Lock ordering adjustment in serialization path

Risk score

Why this scored 55/100

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