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

chaincfg/chainhash: add strict parsing

Public commit record

What the developer wrote

Authored by Boris Nagaev

78/100 · Adequate
chaincfg/chainhash: add strict parsing

Add NewHashFromStrStrict and DecodeStrict for callers that must
parse full txids or block hashes exactly.

Keep NewHashFromStr and Decode lenient for compatibility, but add
NOTE docs steering typical parsing to the strict helpers.

Add tests for the new strict behavior and preserve coverage for the
existing lenient short and odd hex behavior.
✓ Descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Mentions testing or verification
The short version

What changed, and why it matters

This commit adds new strict hash-parsing functions to btcd's chainhash package. The existing lenient functions accept shortened or odd-length hex strings and silently pad them with zeros, which can be risky when parsing transaction or block IDs. The new strict helpers require an exact 64-character hex string. The commit does not switch any callers to the strict versions, so it is a defensive API addition rather than an immediate fix for a known vulnerability.

Recommended action

Review all call sites of NewHashFromStr and Decode throughout btcd and dependent projects to determine which should be migrated to the strict variants, especially those handling user-supplied txids or block hashes. Treat this commit as a preparatory hardening change and follow up with caller migration patches.

Security signals we found

01

Lenient hash parsing can silently accept truncated or odd-length transaction/block IDs, potentially enabling identifier confusion or collision-style attacks.

02

New strict API is added but no existing callers are migrated, so the security benefit is latent until downstream code adopts it.

03

Commit message frames the change as adding strict parsing for callers that must parse full txids or block hashes exactly.

04

No CVE, advisory, or vendor security disclosure is present in the supplied materials.

Risk score

Why this scored 37/100

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