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

hashes: Fix Hkdf::expand panic at max length

Public commit record

What the developer wrote

Authored by Jamil Lambert, PhD

73/100 · Adequate
hashes: Fix Hkdf::expand panic at max length

Hkdf::expand accepts an output buffer up to the RFC-5869 maximum of
255 * T::Hash::LEN bytes, but the u8 counter overflows when incremented
past the final block at that max length.

Replace the u8 counter with a for loop which cannot overflow.

Assisted-by: Claude Opus 4.8
✓ Descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Names security-relevant behavior explicitly
The short version

What changed, and why it matters

This commit fixes a bug in the HKDF key-derivation function where requesting the maximum allowed output length could cause the program to panic (crash) due to a counter overflow. The fix replaces an 8-bit counter that could wrap around past 255 with a loop using a larger integer type, so the maximum-length expansion completes safely.

Recommended action

Upgrade to a version of rust-bitcoin containing this commit. If HKDF output lengths are externally supplied, validate them and ensure the fix is applied. No other immediate mitigation is required because the panic only occurs at the exact maximum allowed length.

Security signals we found

01

Integer overflow in loop counter leading to panic

02

Out-of-bounds memory access via overflowed index

03

Denial-of-service vector: attacker-controlled HKDF output length can trigger crash

04

RFC-5869 maximum output length boundary condition not handled safely

Risk score

Why this scored 62/100

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