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

graph/db/models: fix race condition in Node.PubKey

Public commit record

What the developer wrote

Authored by Elle Mouton

73/100 · Adequate
graph/db/models: fix race condition in Node.PubKey

The PubKey method had a race condition where concurrent calls could
all pass the nil check and race to write to the cached pubKey field.
This is a classic check-then-act race.

Remove the caching entirely to fix the race. The overhead of parsing
a public key is minimal and doesn't justify the added complexity and
race risk of caching.
✓ 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 subtle multi-threading bug in how LND retrieves a node's public key. Multiple parts of the program could call the same method at the same time, and because the method cached the parsed key in a shared field, several threads could try to write that cache simultaneously. That kind of race can corrupt memory or cause crashes in Go. The fix removes the cache entirely and simply parses the key on demand, which is fast enough that caching isn't worth the risk.

Recommended action

Apply the patch. It is a clean, low-risk removal of a racy cache. After applying, run the package tests with the Go race detector enabled (go test -race ./graph/db/models/...) to confirm no remaining races in this code path.

Security signals we found

01

Data race on shared mutable state (check-then-act)

02

Potential memory corruption or panic due to unsynchronized concurrent writes

03

Fix removes caching rather than adding synchronization, indicating low cost of safe alternative

Risk score

Why this scored 37/100

Our methodology →
Potential impact 8/30
Exploitability 5/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.