fix: require admin key on all BFT consensus POST endpoints#6638
fix: require admin key on all BFT consensus POST endpoints#6638BossChaos wants to merge 1 commit into
Conversation
- /bft/message: no auth required for BFT message injection (HIGH) - /bft/view_change: no auth required for BFT view change (HIGH) - /bft/propose: no auth required for epoch proposal trigger (HIGH) All three POST endpoints accepted arbitrary input without admin authentication, allowing unauthorized BFT message injection, view manipulation, and epoch proposal disruption. Fix: add _require_admin() check using RC_ADMIN_KEY + X-Admin-Key header with hmac.compare_digest on all three write endpoints.
| admin_key = os.environ.get("RC_ADMIN_KEY", "") | ||
| if not admin_key: | ||
| return jsonify({'error': 'RC_ADMIN_KEY not configured -- BFT admin endpoints disabled'}), 503 | ||
| provided = request.headers.get("X-Admin-Key", "") |
There was a problem hiding this comment.
This makes /bft/message and /bft/view_change require X-Admin-Key, but the local peer broadcasters at _broadcast_message() and _broadcast_view_change() still call requests.post(...) without that header. With RC_ADMIN_KEY configured, normal peer traffic will be rejected before receive_message() / handle_view_change() runs, so the fix trades public injection for a consensus liveness regression. Please update the broadcast path or use a separate peer-auth mechanism, and add a regression test covering authenticated inter-node BFT traffic.
aisoh877
left a comment
There was a problem hiding this comment.
Thanks for working on closing this unauthenticated BFT POST surface. I think this needs one change before merge.
The new _require_admin() gate is applied to /bft/message and /bft/view_change, but the peer broadcast paths still do not send X-Admin-Key: _broadcast_message() sends only X-Node-ID, and _broadcast_view_change() sends no auth header. Once RC_ADMIN_KEY is configured, every honest peer that receives these broadcasts will reject them with 401, so PRE-PREPARE/PREPARE/COMMIT and view-change propagation stop. If RC_ADMIN_KEY is unset, these routes now return 503 and disable inbound BFT traffic entirely.
I think the fix is to either add matching internal-auth support to the broadcast side and cover it in route/broadcast tests, or keep peer consensus traffic protected by the existing signed-message verification and only require admin auth for the manual /bft/propose endpoint.
I could not run the focused pytest suite in this checkout because the Python environment is missing flask/pytest, but the changed call sites show the regression statically.
|
@BossChaos — closing as NEEDS_FIX per Codex authoritative audit. Good news first: the disclosure-recovery loop worked. Unlike your closed #6559 which hid Why it's NEEDS_FIX (not REJECT or MERGE): Codex authoritative verdict: the inbound auth hardening (requiring admin-key on incoming BFT POSTs) was not paired with corresponding outbound sender changes. Existing peer-to-peer BFT traffic between honest nodes would now be rejected because the senders don't carry the admin-key header. Result: 21 existing tests fail when the patch is applied (per Codex's local validation run). The fix breaks honest peer traffic while closing the unauthenticated attacker path. Required change: pair the inbound auth requirement with either:
Verify by running the failing test suite locally ( Update and ping — happy to pay High (50 RTC) on a clean re-audit. |
|
Closed — NEEDS_FIX. Honest disclosure (good), but fix breaks 21 honest peer-traffic tests. Pair inbound auth with outbound sender change. See comment. |
Summary
Three BFT consensus POST endpoints in
rustchain_bft_consensus.pyaccepted arbitrary input without admin authentication, enabling unauthenticated actors to inject BFT messages, manipulate view state, and trigger unauthorized epoch proposals.Vulnerabilities Fixed
POST /bft/messagePOST /bft/view_changePOST /bft/proposeFix
Added
_require_admin()helper usingRC_ADMIN_KEYenvironment variable +X-Admin-KeyHTTP header withhmac.compare_digesttiming-safe comparison. All three write endpoints now enforce admin authentication before processing.Severity
HIGH — Unauthorized epoch proposals can disrupt BFT consensus. Message injection can corrupt consensus state. View change manipulation can cause denial of service.
Bounty
Bounty #73 | Fix PR | Wallet:
RTC6d1f27d28961279f1034d9561c2403697eb55602