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

graph/db: fix race in DisconnectBlockAtHeight cache access

Public commit record

What the developer wrote

Authored by Elle Mouton

73/100 · Adequate
graph/db: fix race in DisconnectBlockAtHeight cache access

The DisconnectBlockAtHeight method was modifying the rejectCache and
chanCache without holding the cacheMu lock. This caused races with
other operations that properly held the lock, such as AddChannelEdge
which modifies the caches in its OnCommit callback while the batch
scheduler holds cacheMu.

Fix by acquiring cacheMu before removing channels from the caches.
✓ 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 concurrency bug in LND's channel graph database. When disconnecting a block, the code was removing entries from internal caches without holding the proper lock, while other code paths correctly lock the same caches. This can cause data races, potentially leading to corrupted cache state, inconsistent channel graph views, or crashes under concurrent load.

Recommended action

Apply the patch. Consider running the race detector (go test -race) on graph/db package tests covering block disconnect and channel edge addition paths. Review other cache-modifying methods for consistent cacheMu usage.

Security signals we found

01

Concurrency race condition on shared cache

02

Missing mutex lock around cache mutation

03

Potential cache corruption or inconsistent graph state

04

Crash or undefined behavior under concurrent block reorganization and channel updates

Risk score

Why this scored 49/100

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