fix(security): Auth for bounty claim, SSL verification, remove hardcoded admin key#2800
Conversation
…ded admin key
1. beacon_api.py: Add X-Admin-Key authentication to /api/bounties/<id>/claim
- Previously anyone could claim bounties without authentication
- Now requires RC_ADMIN_KEY via X-Admin-Key header (same as complete_bounty)
2. beacon_api.py: Enable SSL verification in sync_bounties
- Previously disabled SSL verification unconditionally
- Now verifies by default; opt-out via RC_DISABLE_SSL_VERIFY=1 env var
3. fleet_immune_system.py: Remove hardcoded admin key fallback
- Previously fell back to 'rustchain_admin_key_2025_secure64' when
RC_ADMIN_KEY env var was not set
- Now requires RC_ADMIN_KEY to be set; endpoints return 503 if missing
- Also uses hmac.compare_digest for timing-safe comparison
RTC: RTC4642c5ee8467f61ed91b5775b0eeba984dd776ba
wuxiaobinsh-gif
left a comment
There was a problem hiding this comment.
PR Review — Security Fixes (#2800)
What I reviewed: PR #2800 — Security fixes in beacon_api.py and fleet_immune_system.py
Finding 1: SSL Verification Fix
The fix enables SSL verification by default and adds opt-out via RC_DISABLE_SSL_VERIFY=1 with a warning log. Correct pattern — secure by default. Minor: import logging is inside conditional block, consider module-level import.
Finding 2: Admin Key Hardcode Fix
The change from hardcoded fallback to returning 503 when RC_ADMIN_KEY is unset is correct. Using hmac.compare_digest() for timing-safe comparison prevents timing attacks. Well done.
Finding 3: Bounty Claim Auth
Adding X-Admin-Key header authentication follows the existing pattern in complete_bounty. Properly closes the unauthenticated bounty claim vulnerability.
Overall: LGTM. 3 substantive technical observations. Qualifies for 2 RTC.
Disclosure: I received RTC compensation for this review.
RTC Wallet: RTC9a39ca2c84f61ca27d96463bcf65b6022b827f85
|
@haoyousun60-create — substantive security work, three real fixes:
Bonus: you also used Payout: 75 RTC (Major-tier security fix — 3 distinct findings, one of which is Critical-tier (auth bypass on bounty claims), executed cleanly with proper crypto primitives). Note on CI: there's a Drop your wallet here for the next batch transfer. Merging with admin override (CI failures are pre-existing, not from this PR). |
… C1 PoC, RC_P2P_SECRET) (#2859) Five tests on main were broken by yesterday's audit fixes (#2812-#2816 + #2800): 1. test_mempool_add_manage_tx_undefined (#2812 follow-up) - Was asserting the BUG exists (manage_tx undefined). After fix, manage_tx IS defined. Updated to assert FIX is in place + smoke-test no NameError. 2. test_pncounter_max_merge_inflation - Imports rustchain_p2p_gossip which raises SystemExit if RC_P2P_SECRET not set. CI workflow didn't set it. Added RC_P2P_SECRET to ci.yml env. 3. test_bounty_lifecycle_workflow (#2800 follow-up) - haoyousun60-create's #2800 added admin auth on /api/bounties/<id>/claim. Test was sending request without X-Admin-Key. Added the header. 4. test_utxo_transfer_rejects_duplicate_nonce (#2814 M2 follow-up) 5. test_utxo_transfer_failed_attempt_does_not_burn_nonce (#2814 M2 follow-up) - M2 fix made amount_rtc / fee_rtc Decimal types internally for precision. Decimal isn't JSON-serializable, so signed-payload construction (json.dumps) and response jsonify both broke. - Cast to float for the signed payload (preserves byte-identical signature bytes vs what wallets compute) and for the response jsonify. - Decimal arithmetic still happens internally for the int(amount * UNIT) conversion, so the precision-loss + overflow guards from M2 are intact. All 6 tests pass locally with the env vars set. Co-authored-by: Scottcjn <scottbphone12@gmail.com>
|
@Scottcjn Wallet for payout: RTC4642c5ee8467f61ed91b5775b0eeba984dd776ba Thank you for the review! Ready to receive the 75 RTC payment. |
Security Fixes
1. Unauthenticated Bounty Claim (
beacon_api.py)/api/bounties/<id>/claimhad no authentication — anyone could claim any bountyX-Admin-Keyheader authentication (same pattern ascomplete_bounty)RC_ADMIN_KEYnot configured2. SSL Verification Disabled (
beacon_api.py)sync_bountiesunconditionally disabled SSL certificate verificationRC_DISABLE_SSL_VERIFY=1env var with a warning log3. Hardcoded Admin Key (
fleet_immune_system.py)register_fleet_endpoints()fell back to hardcoded defaultrustchain_admin_key_2025_secure64whenRC_ADMIN_KEYenv var was unsetRC_ADMIN_KEYnot set. Also switched tohmac.compare_digestfor timing-safe comparison.RTC:
RTC4642c5ee8467f61ed91b5775b0eeba984dd776ba