Skip to content

Guard Forknote parent blockchain branch depth#34

Merged
MoneroOcean merged 1 commit into
masterfrom
codex/fix-oom-crash-in-forknote-parent-block-parsing
May 29, 2026
Merged

Guard Forknote parent blockchain branch depth#34
MoneroOcean merged 1 commit into
masterfrom
codex/fix-oom-crash-in-forknote-parent-block-parsing

Conversation

@MoneroOcean
Copy link
Copy Markdown
Owner

Motivation

  • Prevent an attacker-controlled merge-mining depth (read from tx_extra as an untrusted varint) from driving an unchecked std::vector::resize during deserialization which can OOM or abort the process.
  • The unsafe path is reachable because parent block parsing for v2/v3 blocks deserializes a merge-mining tag and uses its depth directly to size the blockchain_branch vector.
  • Ensure deserialization validates the claimed depth against the remaining input before any allocation occurs.

Description

  • Add load/save-aware helper templates has_enough_blockchain_branch_bytes(Archive&, size_t, ...) that return true for saving and perform a remaining-bytes check for loading.
  • Invoke the load-side check immediately before PREPARE_CUSTOM_VECTOR_SERIALIZATION(mm_tag.depth, ...) so deserialization returns false when mm_tag.depth claims more crypto::hash entries than remain.
  • Change implemented in src/cryptonote_basic/cryptonote_basic.h (helper templates + early validation before resizing blockchain_branch).

Testing

  • Ran git diff --check which completed successfully and showed no whitespace/style issues.
  • Attempted npm install --no-audit --no-fund --no-package-lock to build the native addon and run tests, but the run was blocked by the npm registry returning 403 Forbidden, so the native build/tests could not be executed in this environment.
  • Attempted a C++ syntax-only check with g++ -std=c++17 -I src -I src/contrib/epee/include -fsyntax-only src/cryptonote_basic/cryptonote_format_utils.cpp, but local compilation was prevented by missing Boost headers and restricted apt-get access in the runner environment.

Codex Task

@MoneroOcean MoneroOcean merged commit 8e8cfc4 into master May 29, 2026
3 checks passed
@MoneroOcean MoneroOcean deleted the codex/fix-oom-crash-in-forknote-parent-block-parsing branch May 29, 2026 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant