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

Use size_t instead of int for RFC6979 outlen copy

Public commit record

What the developer wrote

Authored by John Moffett

60/100 · Adequate
Use size_t instead of int for RFC6979 outlen copy

If outlen is > INT_MAX, could trigger segfault or hang after copy
int now = outlen.
✓ 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 variable type mismatch in the RFC6979 nonce-generation code. The code copies a `size_t` length value into an `int` variable. On platforms where `int` is 32 bits and `size_t` is 64 bits, requesting more than about 2 billion bytes of output would cause the `int` to wrap around to a negative value. That negative value would then be treated as a very large positive number in later comparisons, potentially causing the loop to run far too long or to access memory out of bounds, which could crash or hang the program. In practice, callers inside libsecp256k1 request only 32 bytes, so the bug is unlikely to be reachable from normal use.

Recommended action

Apply the patch. Review any external or downstream callers of `secp256k1_rfc6979_hmac_sha256_generate` to confirm they do not pass attacker-controlled lengths. Consider adding an explicit bounds check or assertion on `outlen` for defense in depth, even though the fix removes the immediate type mismatch.

Security signals we found

01

Integer width truncation from size_t to int

02

Potential signed/unsigned conversion defect leading to out-of-bounds or denial-of-service

03

Fix located in cryptographic nonce generation path (RFC6979 HMAC-SHA256)

04

No explicit security advisory or CVE referenced in commit materials

Risk score

Why this scored 34/100

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