Skip to content

fix: guard NiPoPow scorex_parse against allocation bomb#855

Open
mwaddip wants to merge 1 commit into
ergoplatform:developfrom
mwaddip:fix/nipopow-alloc-bomb
Open

fix: guard NiPoPow scorex_parse against allocation bomb#855
mwaddip wants to merge 1 commit into
ergoplatform:developfrom
mwaddip:fix/nipopow-alloc-bomb

Conversation

@mwaddip
Copy link
Copy Markdown

@mwaddip mwaddip commented Apr 9, 2026

Summary

  • A crafted P2P payload can set num_prefixes or other size fields to 0x7FFFFFFF, causing Vec::with_capacity to request ~790 GB and SIGABRT the node
  • Adds sanity-limit guards to all five attacker-controlled size fields in NipopowProof::scorex_parse and PoPowHeader::scorex_parse
  • Adds tests confirming huge values return Err instead of crashing

Guarded fields

Location Field Cap
NipopowProof::scorex_parse num_prefixes 20,000
NipopowProof::scorex_parse num_suffix_tail 20,000
PoPowHeader::scorex_parse header_size 10,000 bytes
PoPowHeader::scorex_parse interlinks_size 10,000
PoPowHeader::scorex_parse proof_bytes 1,000,000 bytes

Test plan

  • crafted_huge_prefix_count_returns_errnum_prefixes = 0x7FFFFFFFErr
  • crafted_huge_header_size_returns_errheader_size = 0x7FFFFFFFErr
  • crafted_header_size_just_over_limit_returns_errheader_size = 10,001Err
  • Existing nipopowproof_roundtrip proptest still passes

🤖 Generated with Claude Code

…d input

A crafted P2P payload could set num_prefixes/num_suffix_tail to
0x7FFFFFFF, causing Vec::with_capacity to request ~790 GB and SIGABRT
the node. Add sanity caps to all five attacker-controlled size fields
in NipopowProof::scorex_parse and PoPowHeader::scorex_parse.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@kushti kushti requested review from Alesfatalis and sethdusek April 9, 2026 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants