Skip to content

fix(beldex-storage-server): add missing return statement after monitor_error in MQBase pubkey validation - #14

Open
localtrade1 wants to merge 1 commit into
Beldex-Coin:masterfrom
localtrade1:localtrade1-patch-1
Open

fix(beldex-storage-server): add missing return statement after monitor_error in MQBase pubkey validation#14
localtrade1 wants to merge 1 commit into
Beldex-Coin:masterfrom
localtrade1:localtrade1-patch-1

Conversation

@localtrade1

@localtrade1 localtrade1 commented Aug 30, 2026

Copy link
Copy Markdown

Motivation

This PR fixes a critical control-flow vulnerability in beldex-storage-server (beldexss/server/mqbase.cpp), identified during the Beldex workspace security audit[cite: 30]. Previously, when an invalid public key size was encountered under the p= parameter handling block, the code invoked monitor_error but omitted a return statement. This caused execution to fall through on an unauthenticated path with attacker-controlled data, leading to heap out-of-bounds reads and malformed protocol responses.

Modifications

  • Add Missing Return Guard (beldexss/server/mqbase.cpp):
    • Inserted an explicit return statement immediately following the monitor_error call when the pubkey size does not equal 33 bytes[cite: 30].
    • Ensured malicious or malformed public key requests are terminated safely without falling through to dangerous memory indexing operations.

Checklist

  • Format your code according to the Contributor Guide.
  • Add unit tests as outlined in the Contributor Guide.
  • Update documentation as needed, including docstrings or example tutorials.

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

* **Bug Fixes**
  * Improved validation of monitor message public keys.
  * Invalid or incomplete keys now stop processing immediately, preventing malformed responses and potential verification errors.


<!-- end of auto-generated comment: release notes by coderabbit.ai -->

…r_error in MQBase pubkey validation

## Motivation

This PR fixes a critical control-flow vulnerability in `beldex-storage-server` (`beldexss/server/mqbase.cpp`), identified during the Beldex workspace security audit[cite: 30]. Previously, when an invalid public key size was encountered under the `p=` parameter handling block, the code invoked `monitor_error` but omitted a `return` statement. This caused execution to fall through on an unauthenticated path with attacker-controlled data, leading to heap out-of-bounds reads and malformed protocol responses.

## Modifications

* **Add Missing Return Guard (`beldexss/server/mqbase.cpp`)**:
  * Inserted an explicit `return` statement immediately following the `monitor_error` call when the pubkey size does not equal 33 bytes[cite: 30].
  * Ensured malicious or malformed public key requests are terminated safely without falling through to dangerous memory indexing operations.

## Checklist

- [x] Format your code according to the Contributor Guide.
- [ ] Add unit tests as outlined in the Contributor Guide.
- [x] Update documentation as needed, including docstrings or example tutorials.
```[cite: 30]
@coderabbitai

coderabbitai Bot commented Aug 30, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: a7b687dd-ddaf-4140-b26d-7e0f009112b4

📥 Commits

Reviewing files that changed from the base of the PR and between 8984149 and f541aba.

📒 Files selected for processing (1)
  • beldexss/server/mqbase.cpp

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


📝 Walkthrough

Walkthrough

The monitor message handler now returns immediately when the p= pubkey is not 33 bytes. The existing BAD_PUBKEY monitor error remains unchanged.

Changes

Monitor pubkey validation

Layer / File(s) Summary
Reject invalid monitor pubkeys
beldexss/server/mqbase.cpp
The pubkey size check returns the monitor_error result for invalid pubkeys instead of continuing with verification and reply construction.

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

Merge Risk: ⚪ Minimal · up to f541a

The change immediately stops processing malformed public keys after validation fails. It is localized and does not introduce an actionable merge-blocking risk beyond normal checks and review.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding a missing return after monitor_error during public key validation.
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.
  • Fix all pre-merge checks with AI
✨ 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.

@localtrade1

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 31, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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