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

Merge bitcoin-core/secp256k1#1910: scratch: reject sizes that overflow when added to header

Public commit record

What the developer wrote

Authored by merge-script

86/100 · Strong
Merge bitcoin-core/secp256k1#1910: scratch: reject sizes that overflow when added to header

3d4340d17325a6732108423f9d3e54de99539a60 scratch: reject sizes that overflow when added to header (Sebastian Falbesoner)

Pull request description:

We only use scratch space internally, so this is not an issue for the user (scratch API functions have been removed since 0.6.0, see #1620), but fixing this might still make sense to prepare for the unlikely case that we expose the scratch API again in the future. An alternative could be to simply delete the scratch space functionality already, as e.g. done in PR #1789.

Reported by [Project Loupe](https://github.com/project-loupe)

ACKs for top commit:
apoelstra:
utACK 3d4340d17325a6732108423f9d3e54de99539a60
real-or-random:
utACK 3d4340d17325a6732108423f9d3e54de99539a60

Tree-SHA512: 8e380919a48445d8df46a568e4fcbcbe31b5b5668586942d1eaa1b90b4e0669548d5ca831c8dde484b869c7e95faacb608491738a59c5e1ee15d4084acc7ead6
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Links an issue, advisory, or supporting reference✓ Names security-relevant behavior explicitly
The short version

What changed, and why it matters

This commit fixes an integer overflow bug in the library's internal scratch-space memory allocator. If a caller requested a scratch space with a size near the maximum possible value, adding the allocator's own bookkeeping header could wrap around to a tiny total size. That tiny allocation would then be used as if it were huge, potentially causing memory corruption. However, the scratch-space API is no longer exposed to users, so normal applications cannot trigger this.

Recommended action

No urgent action for end users: the scratch API is internal and not reachable from public interfaces. Developers integrating libsecp256k1 should ensure they are on a version containing this fix if they build with internal symbols exposed or if the scratch API is reintroduced in the future.

Security signals we found

01

Integer overflow in size calculation

02

Heap allocation size mismatch

03

Potential buffer overflow / out-of-bounds write

04

Internal-only API reduces practical exposure

Risk score

Why this scored 27/100

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