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

lnwallet: fix limboMtx/intentMtx lock order inversion in PsbtFundingVerify

Public commit record

What the developer wrote

Authored by LNBiG

73/100 · Adequate
lnwallet: fix limboMtx/intentMtx lock order inversion in PsbtFundingVerify

PsbtFundingVerify acquired intentMtx and then limboMtx, while
handleFundingCancelRequest, which runs in the wallet's single requestHandler
goroutine, acquires the two in the opposite order. With PSBT or batch funding
both paths run concurrently, so the two goroutines can deadlock.

The consequences are severe and node wide: requestHandler is the only executor
of every ChannelReservation method, and those methods are unconditional round
trips with neither a timeout nor a quit escape. Once it is stuck, a peer
disconnect parks funding.Manager's resMtx forever in CancelPeerReservations,
and the next zombie sweeper tick kills reservationCoordinator on resMtx.RLock.
From that moment the node can neither open nor accept channels, freshly
confirmed channels are stuck in the channelReadySent opening state and are
never added to the graph nor announced, and no log line is emitted about any of
it. Only a restart recovers.

Look the channel reservation up, and release limboMtx, before acquiring
intentMtx, and document the required order on the mutex declaration.
✓ 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 classic deadlock bug in LND's wallet code. Two different code paths were acquiring the same two locks in opposite orders, which could cause the wallet's single request handler goroutine to freeze permanently. Once frozen, the node could no longer open or accept any Lightning channels, and newly confirmed channels would get stuck without being announced to the network. Only restarting the node would recover. The fix reorders the lock acquisition so both paths use the same order, and documents the rule.

Recommended action

Apply the patch to ensure consistent lock ordering. Operators running nodes with PSBT or batch funding should upgrade promptly, as the deadlock can silently disable all channel funding activity until restart.

Security signals we found

01

Deadlock between two mutexes acquired in opposite orders

02

Single requestHandler goroutine becomes permanently wedged

03

All ChannelReservation methods blocked without timeout or quit escape

04

funding.Manager resMtx held indefinitely on peer disconnect

05

zombie sweeper kills reservationCoordinator on resMtx.RLock

06

Node cannot open or accept channels after deadlock

07

Confirmed channels stuck in channelReadySent state, never added to graph or announced

08

No log lines emitted during the failure

09

Only node restart recovers

Risk score

Why this scored 85/100

Our methodology →
Potential impact 28/30
Exploitability 18/25
Stealth signal 13/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.