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

wallet: bound-check shachain_known pos on load

Public commit record

What the developer wrote

Authored by cdecker

68/100 · Adequate
wallet: bound-check shachain_known pos on load

Keep the loaded pos within the known[] array like the other defensive
checks in the channel loader, so a malformed row fails loudly instead of
indexing out of range.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

Changelog-Fixed: wallet: an out-of-range shachain index in the database is now rejected at load instead of read out of bounds.
(cherry picked from commit fdd7b11e9f38eb2d3fa5515c00e64f0ad17d63fc)
✓ Descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context
The short version

What changed, and why it matters

This update fixes a bug in Core Lightning's wallet code where it reads a 'position' value from its database and uses it directly as an array index without first checking whether it is valid. If the database contained an out-of-range value, the program could read or write memory outside the intended array, which can cause crashes or unpredictable behavior. The fix adds a simple bounds check and makes the program stop with a clear error if the value is invalid.

Recommended action

Treat as a low-to-moderate reliability/security fix. Backport to maintained branches if the affected code is present. Review other channel/wallet loaders for similar missing bounds checks on database-derived array indices.

Security signals we found

01

Out-of-bounds array index from database value

02

Defensive bounds check added in wallet loading path

03

db_fatal() used to fail loudly on malformed row

04

Changelog labels this as a fixed wallet issue

Risk score

Why this scored 57/100

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