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

sqldb: scope DeleteFailedAttempts query to payment's own attempts

Public commit record

What the developer wrote

Authored by ziggie

73/100 · Adequate
sqldb: scope DeleteFailedAttempts query to payment's own attempts

The previous query used an IN subquery that scanned all failed
resolutions across all payments (O(N) where N = total failed attempts
globally). Replace with a correlated EXISTS subquery that only checks
resolutions for the specific payment's attempts, making it O(k) where
k = attempts for this payment (typically 1-5).
✓ 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 database cleanup query in LND's payment handling. The old query could accidentally consider failed payment attempts from other payments because it looked at all failed attempts globally rather than only the current payment's attempts. The new query restricts the check to the specific payment being cleaned up, which also makes it much faster. There is no direct evidence this caused a security vulnerability, but the old behavior is a logic bug that could lead to deleting the wrong data under rare conditions.

Recommended action

Review whether the old query could have caused incorrect deletion of HTLC attempts across payments in production; consider adding a regression test and verifying that attempt_index is never reused across payments in a way that could reintroduce this issue. No immediate emergency action is indicated.

Security signals we found

01

Query logic bug: non-unique attempt_index used without payment_id correlation

02

Potential cross-payment data deletion risk

03

Fix scopes deletion to payment's own attempts

04

No explicit security framing by vendor

Risk score

Why this scored 29/100

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