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

miniscript: Use a reference to key_exp_index in KeyParser

Public commit record

What the developer wrote

Authored by Ava Chow

65/100 · Adequate
miniscript: Use a reference to key_exp_index in KeyParser

For key_exp_index to count correctly for miniscript expressions,
KeyParser should hold a reference to it.
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides an explanatory body
The short version

What changed, and why it matters

This change fixes how Bitcoin Core counts key expressions when parsing Miniscript descriptors. Previously, the parser kept a private copy of a counter (m_offset), so updates inside the parser did not propagate back to the caller. By switching to a shared reference (m_expr_index), the caller's counter stays correct across nested or repeated Miniscript parsing. A wrong counter could lead to incorrect descriptor metadata, which in wallet software might cause addresses, derivation paths, or key identifiers to be mis-indexed. There is no direct remote exploit shown in the diff, but the bug could affect wallet correctness and user funds if a descriptor relying on the counter is used.

Recommended action

Review related descriptor parsing tests to ensure key_exp_index is correctly incremented across nested miniscripts, multipath descriptors, and repeated ParseScript calls. Add regression tests that verify key expression indices round-trip correctly. Consider auditing other parser state that is passed by value instead of by reference for similar synchronization issues.

Security signals we found

01

State synchronization bug between parser and caller

02

Descriptor parsing correctness issue

03

Potential key index miscounting in Miniscript descriptors

04

No explicit bounds check or overflow handling visible in the diff

Risk score

Why this scored 47/100

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