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

ellswift: don't declassify or leave sk in sha256 buffer

Public commit record

What the developer wrote

Authored by furszy

73/100 · Adequate
ellswift: don't declassify or leave sk in sha256 buffer

secp256k1_ellswift_create assumes sha256 clears the data in its buffer
after hashing it, which is not the case. So we shouldn't declassify the
whole struct, only the hash result. We should also clear it at the end,
so the sk doesn't linger on the stack when no aux rnd is given.
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context
The short version

What changed, and why it matters

This commit fixes a small but real privacy bug in the ElligatorSwift key-encoding helper. The code had wrongly assumed that the SHA-256 hashing routine wipes its internal buffer after feeding data in, so it marked the whole hash state as safe-to-leak and did not clear it. Because the buffer still held a copy of the secret key, that secret key could remain in stack memory longer than intended, especially when no extra random data (auxrnd) was provided. The patch narrows the 'declassify' to only the actual hash output/state and explicitly clears the SHA-256 buffer at the end, removing the leftover secret key from the stack.

Recommended action

Treat as a low-to-moderate security hardening fix. Backport to stable branches that include the ElligatorSwift module, and verify that any downstream code using this module is rebuilt. No immediate incident response is required unless the target threat model includes local stack-memory attacks against this specific API.

Security signals we found

01

Secret key material retained in SHA-256 internal buffer after write

02

Over-broad declassification of struct containing secret key copy

03

Missing stack scrubbing of hash state before function return

04

Corrective narrowing of declassify to hash state only

05

Addition of explicit secp256k1_sha256_clear call

Risk score

Why this scored 47/100

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