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

sqldb: use version-specific staleness checks in UpsertChannelPolicy

Public commit record

What the developer wrote

Authored by Elle Mouton

73/100 · Adequate
sqldb: use version-specific staleness checks in UpsertChannelPolicy

Update the UpsertChannelPolicy query to apply different staleness
checks based on gossip version. For v1 policies, continue checking
last_update timestamps. For v2 policies, check block_height instead,
using >= comparison to handle policies from the same block.

The version-specific WHERE clause ensures that policy updates are only
applied when they contain newer information according to the versioning
scheme appropriate for that gossip version.
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context
The short version

What changed, and why it matters

This change fixes how LND stores routing policy updates received over the Lightning network gossip protocol. Different gossip versions use different freshness indicators: v1 uses a timestamp, while v2 uses a block height. Previously the code always compared timestamps, which could cause newer v2 policies to be ignored if their timestamp was older, or stale v2 policies to overwrite newer ones. The patch makes the database update conditional on the correct freshness field for each gossip version.

Recommended action

Treat as a correctness/security hardening fix and include in the next maintenance release. Review related graph policy code paths to ensure no other queries still rely solely on last_update for v2 policies. No immediate emergency response is indicated absent evidence of active exploitation.

Security signals we found

01

Incorrect freshness comparison could allow stale routing policies to overwrite newer ones

02

Version-specific conditional logic added to SQL upsert

03

v2 gossip policies now use block_height instead of last_update for staleness

04

NULL handling added for both version branches to initialize empty rows

Risk score

Why this scored 46/100

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