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

Harden count_distinct_keys_info to correctly count the used keys

Public commit record

What the developer wrote

Authored by Salvatore Ingala

65/100 · Adequate
Harden count_distinct_keys_info to correctly count the used keys

This avoids registering wallet policies that contain unused xpubs
that are not referenced in the descriptor template.
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides an explanatory body
The short version

What changed, and why it matters

This commit fixes a bug in Ledger's Bitcoin app that could let a wallet policy slip through registration even when it contained unused or out-of-range public keys. The old code simply looked at the highest key index referenced in the wallet descriptor and assumed every key up to that number was used. That meant an attacker could craft a policy where the user's own key was listed as an unused extra key while the descriptor only required the attacker's key. The fix now explicitly counts which keys are actually referenced and rejects policies with gaps or unreferenced keys.

Recommended action

Treat this as a security hardening fix and include it in the next firmware release. Review related wallet policy validation paths for similar max-index assumptions, and consider whether the internal-key check can be bypassed through other descriptor constructions.

Security signals we found

01

Logic flaw in wallet policy validation

02

Potential bypass of internal-key ownership check via unused key slots

03

Bounds checking added for key indices

04

New negative test case for gap/unreferenced key attack

Risk score

Why this scored 67/100

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