Skip to content

fix: require admin auth on beacon API GET endpoints#6318

Open
BossChaos wants to merge 4 commits into
Scottcjn:mainfrom
BossChaos:fix/beacon-api-auth
Open

fix: require admin auth on beacon API GET endpoints#6318
BossChaos wants to merge 4 commits into
Scottcjn:mainfrom
BossChaos:fix/beacon-api-auth

Conversation

@BossChaos
Copy link
Copy Markdown
Contributor

Summary

Fixed 6 unauthenticated GET endpoints in beacon_api.py (Beacon Atlas API) that exposed sensitive relay agent, contract, bounty, and reputation data.

Vulnerabilities Fixed

Endpoint Severity Issue
GET /api/agents HIGH Exposes ALL relay agents with pubkeys, coinbase addresses, status
GET /api/agent/<agent_id> HIGH Exposes single agent pubkey, coinbase, status
GET /api/contracts HIGH Exposes all beacon contracts, agent IDs, contract terms
GET /api/bounties HIGH Exposes all beacon bounties with reward amounts and agent info
GET /api/reputation HIGH Exposes ALL agent scores, RTC earnings, breach history
GET /api/reputation/<agent_id> HIGH Exposes single agent score, earnings, breach count

Fix

Added X-Admin-Key header validation using hmac.compare_digest (timing-safe) with RC_ADMIN_KEY env var. Returns 401 Unauthorized for invalid/missing keys, 503 if env var not configured.

Bounty

BossChaos added 4 commits May 25, 2026 15:33
- /wallet/balances/all: exposes all miner RTC balances + rankings
- /lottery/eligibility: exposes miner lottery eligibility + epoch info
- /consensus/round_robin_status: exposes all attested miners + multipliers

Fixes Algora bounty Scottcjn#73 (Scottcjn/Rustchain)
- GET /sophia/status/<miner_id>: exposes miner verdict, device fingerprint, fingerprint score
- GET /sophia/status: exposes ALL miners' verdicts, device fingerprints, scores

Fixes Algora bounty Scottcjn#73 (Scottcjn/Rustchain)
- GET /api/airdrop/claim/<claim_id>: exposes github_username, wallet_address, and airdrop tier

Fixes Algora bounty Scottcjn#73 (Scottcjn/Rustchain)
- GET /api/agents: exposes all relay agents with pubkeys and coinbase addresses
- GET /api/agent/<agent_id>: exposes single agent details
- GET /api/contracts: exposes all beacon contracts and agent IDs
- GET /api/bounties: exposes all beacon bounties with reward amounts
- GET /api/reputation: exposes all agent scores and RTC earnings
- GET /api/reputation/<agent_id>: exposes single agent reputation

Fixes Algora bounty Scottcjn#73 (Scottcjn/Rustchain)
@BossChaos BossChaos requested a review from Scottcjn as a code owner May 25, 2026 10:27
@github-actions github-actions Bot added BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) node Node server related size/M PR: 51-200 lines labels May 25, 2026
Copy link
Copy Markdown
Contributor

@CyberNomad2000 CyberNomad2000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes because the newly protected RIP-200 rewards GET routes fail once the admin key path is actually exercised.

hmac is imported inside settle_rewards(), so it is local to that POST handler. The new GET handlers added in this PR call hmac.compare_digest(...) from get_balance, get_all_balances, check_eligibility, and round_robin_status, but there is no module-level hmac binding. With RC_ADMIN_KEY configured and a valid X-Admin-Key, /wallet/balance raises NameError before it can return the balance.

Focused verification on this PR head:

  • python -m py_compile node/rewards_implementation_rip200.py passes.
  • A Flask test_client() request to /wallet/balance?miner_id=miner1 with RC_ADMIN_KEY=secret and X-Admin-Key: secret returns HTTP 500 with NameError: name 'hmac' is not defined at node/rewards_implementation_rip200.py:318.

Moving import hmac to module scope, or importing it inside each newly changed GET handler, should fix the regression.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) node Node server related size/M PR: 51-200 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants