Skip to content

Fix unguarded worker_index read and harden POS commit-reveal - #216

Open
Tore-tto wants to merge 1 commit into
Beldex-Coin:devfrom
Tore-tto:dev
Open

Fix unguarded worker_index read and harden POS commit-reveal#216
Tore-tto wants to merge 1 commit into
Beldex-Coin:devfrom
Tore-tto:dev

Conversation

@Tore-tto

Copy link
Copy Markdown
  • master_node_voting: the signature-failure log read quorum.workers[vote.state_change.worker_index] for all vote types, but worker_index only exists on obligation votes -- for a checkpoint vote it aliases attacker-controlled bytes and indexes an empty vector. Guard it by vote type. Also re-enable the two success logs at MTRACE (level 3) instead of leaving them commented out.

  • pos: only accept a random value reveal from a quorum position that actually committed a hash, so the commit-reveal binding is enforced locally rather than relying on the stage timeout.

  • pos: drop the dead std::sample in signature selection and fix the comment -- the loop always used the first N.

-master_node_voting: the signature-failure log read
quorum.workers[vote.state_change.worker_index] for all vote types, but
worker_index only exists on obligation votes -- for a checkpoint vote it
aliases attacker-controlled bytes and indexes an empty vector. Guard it by
vote type. Also re-enable the two success logs at MTRACE (level 3) instead
of leaving them commented out.

-pos: only accept a random value reveal from a quorum position that actually
committed a hash, so the commit-reveal binding is enforced locally rather
than relying on the stage timeout.

-pos: drop the dead std::sample in signature selection and fix the comment --
the loop always used the first N.
@coderabbitai

coderabbitai Bot commented Aug 21, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 80f9845b-53e7-40af-b38e-62fff09b0d61

📥 Commits

Reviewing files that changed from the base of the PR and between 36aaeaf and c8e0c11.

📒 Files selected for processing (2)
  • src/cryptonote_core/master_node_voting.cpp
  • src/cryptonote_core/pos.cpp

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Improved validation of random-value messages, rejecting messages that lack the required prior verification data.
    • Corrected vote-signature error handling for different vote types, preventing invalid data access during verification.
    • Final block signatures are now selected consistently from the lowest participating validator positions, improving determinism and reliability.
  • Diagnostics
    • Added trace-level logging for successfully verified signatures to support improved troubleshooting.

Walkthrough

The changes update vote-signature logging, reject random values without committed hashes, and replace random final-signature selection with deterministic selection of the lowest participating validator positions.

Changes

Voting and PoS validation

Layer / File(s) Summary
Vote signature logging
src/cryptonote_core/master_node_voting.cpp
Accepted signatures now use trace logging. Invalid-signature logs access worker details only for obligation votes and validator details for other vote types.
PoS validation and signature selection
src/cryptonote_core/pos.cpp
Random values without committed hashes are rejected. Final signatures use the lowest participating validator positions, while the minimum-signature assertion remains.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to c8e0c

The changes are merge-ready after normal checks and review; no actionable merge-blocking risk remains.

Suggested reviewers: victor-tucci

Poem

A rabbit checks each vote with care,
No hash, no random value there.
Lowest validators lead the way,
While trace logs mark the valid day.
The signature set stays neat—
Hop, hop, review complete!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the worker_index safety fix and the POS commit-reveal hardening.
Description check ✅ Passed The description accurately explains all major changes in the voting and proof-of-stake code.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

1 participant