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

taproot: fix merkle path length check

Public commit record

What the developer wrote

Authored by Jon Griffiths

60/100 · Adequate
taproot: fix merkle path length check

Per BIP-0341 path lengths are limited to 128 or less.
✓ 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 validation check in a Bitcoin-related cryptographic library (libwally-core). Specifically, it corrects how the code verifies the length of a 'merkle path' used in Taproot transactions. Before the fix, the code only checked that the path length was a multiple of 32 bytes, but did not enforce the BIP-0341 rule that a Taproot merkle path can have at most 128 such 32-byte elements. The new check also incorrectly tries to limit the length, but contains a bug: it checks `val_len % SHA256_LEN > 128u`, which compares a remainder (always 0 to 31) against 128, so it never triggers. This means the intended 128-element limit is still not actually enforced, making the fix partial or ineffective.

Recommended action

Review and correct the length check. The intended test should likely be `val_len / SHA256_LEN > 128` (or `val_len > 128 * SHA256_LEN`) to enforce BIP-0341's 128-element merkle path limit. Add unit tests covering paths of exactly 128 and 129 elements, empty paths, and non-multiple-of-32 lengths.

Security signals we found

01

Taproot merkle path length validation

02

BIP-0341 compliance

03

Partial or ineffective fix

04

Possible integer arithmetic/logic bug in security check

Risk score

Why this scored 58/100

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