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

graph/db/models: fix race conditions in ChannelEdgeInfo

Public commit record

What the developer wrote

Authored by Elle Mouton

73/100 · Adequate
graph/db/models: fix race conditions in ChannelEdgeInfo

Both NodeKey1 and NodeKey2 methods had the same race condition as the
Node.PubKey method, where concurrent calls could race to write to the
cached fields.

Remove the caching for the same reasons: parsing overhead is minimal
and doesn't justify the complexity and race risk.
✓ 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 race condition in LND's graph database model. Two methods that return public keys for channel partners were caching parsed keys in struct fields without any synchronization. If multiple goroutines called these methods at the same time, they could write to the same memory field simultaneously, leading to undefined behavior or crashes. The fix removes the caching entirely and simply parses the key each time, because parsing is cheap and the cache wasn't worth the risk.

Recommended action

Apply the patch. After applying, run the Go race detector (go test -race) on graph/db/models tests and any code paths that concurrently access ChannelEdgeInfo. Consider auditing other lazy-cached accessors in the codebase for similar patterns.

Security signals we found

01

Data race on shared mutable struct fields

02

Unsynchronized lazy initialization (read-modify-write)

03

Fix removes caching rather than adding locks, citing low parsing overhead

04

Reference to prior similar fix in Node.PubKey suggests pattern of race-prone caching

Risk score

Why this scored 44/100

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