fix: require admin auth on Hall of Rust GET endpoints#6319
Conversation
- /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)
9 unauthenticated GET endpoints exposed miner_id, hardware fingerprints, rust scores, and attestation counts: - /hall/machine/<fingerprint>, /hall/leaderboard, /hall/stats - /hall/random_fact, /hall/machine_of_the_day, /hall/fleet_breakdown - /hall/timeline, /api/hall_of_fame/leaderboard, /api/hall_of_fame/machine Fixes Algora bounty Scottcjn#73 (Scottcjn/Rustchain)
CyberNomad2000
left a comment
There was a problem hiding this comment.
Requesting changes.
I checked head 751f49c99bb772a3d5acf20f2e2676b035f4fb84 locally.
Findings:
-
node/rewards_implementation_rip200.pyuseshmac.compare_digest(...)in the newly protected wallet/lottery GET handlers, buthmacis only imported insidesettle_rewards(). WithRC_ADMIN_KEYconfigured and a validX-Admin-Key,/wallet/balance?miner_id=miner1returns HTTP 500 withNameError: name 'hmac' is not defined. -
The PR turns the public Hall of Rust leaderboard APIs into admin-only endpoints. Existing callers under
web/hall-of-fame/index.html,explorer/static/js/explorer.js,miners/linux/rustchain_living_museum.py, and docs still consume these routes without an admin header. Existingnode/tests/test_hall_of_rust_limit_validation.pyalso now fails because invalid public requests receive 401 before the documented limit validation path.
Validation run:
python -m py_compile node/rewards_implementation_rip200.py node/hall_of_rust.py node/beacon_api.py node/airdrop_v2.py node/sophia_attestation_inspector.py
# passed
Focused Flask probe for /wallet/balance?miner_id=miner1 with RC_ADMIN_KEY=secret and X-Admin-Key=secret
# 500, NameError: name 'hmac' is not defined at node/rewards_implementation_rip200.py:318
RC_ADMIN_KEY=0123456789abcdef0123456789abcdef python -m pytest node/tests/test_hall_of_rust_limit_validation.py -q
# 6 failed: expected 400/200 public leaderboard responses now return 401
shadow88sky
left a comment
There was a problem hiding this comment.
Thanks for the Hall of Rust auth-hardening work. I verified the changed files compile and the diff itself is whitespace-clean:
.venv/bin/python -m py_compile node/airdrop_v2.py node/beacon_api.py node/hall_of_rust.py node/rewards_implementation_rip200.py node/sophia_attestation_inspector.py-> passesgit diff --check $(git rev-list --max-parents=0 HEAD)..HEAD-> passes
I need to request changes because this currently breaks both CI and the existing Hall of Rust API behavior/tests.
First, the PR CI test job is failing with the same newly protected beacon GET flows returning auth errors where tests still expect successful reads:
tests/test_beacon_atlas_behavior.py::TestBeaconAtlasAPIBehavior::test_bounty_completion_updates_reputation->401 != 200tests/test_beacon_atlas_behavior.py::TestBeaconAtlasAPIBehavior::test_bounty_lifecycle_workflow->401 != 200tests/test_beacon_atlas_behavior.py::TestBeaconAtlasAPIBehavior::test_create_contract_workflow->401 != 200- plus two
KeyError: 0failures from/api/contractsreturning an auth object instead of the expected list
Second, the Hall of Rust changes protect endpoints that existing tests and docstrings treat as public/read APIs. This focused command now fails 9 existing tests:
PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 .venv/bin/python -m pytest node/tests/test_hall_of_rust_limit_validation.py node/tests/test_hall_of_rust_error_responses.py tests/test_explorer_hall_of_rust_current_year.py -q
Examples:
/api/hall_of_fame/leaderboard?limit=abcnow returns 401 before limit validation, but the existing contract expects 400./hall/leaderboard?limit=now returns 401 instead of the existing 200/default-limit behavior./hall/statsnow returns 401 instead of preserving the existing 200/500 behavior covered by tests./hall/machine_of_the_daynow returns 401 instead of the current public machine spotlight response.
If these endpoints are intended to become admin-only, the PR needs to update the affected tests and any public UI/caller expectations at the same time. If the public Hall of Fame/leaderboard endpoints should stay embeddable, this should narrow auth to only the sensitive machine-detail/admin-style routes and keep public listing/stat/fun-fact behavior intact.
Summary
Fixed 9 unauthenticated GET endpoints in
hall_of_rust.pythat exposed miner identities and hardware intelligence.Vulnerabilities Fixed
GET /hall/machine/<fingerprint>GET /hall/leaderboardGET /hall/statsGET /hall/random_factGET /hall/machine_of_the_dayGET /hall/fleet_breakdownGET /hall/timelineGET /api/hall_of_fame/leaderboardGET /api/hall_of_fame/machineFix
Added
_require_admin()helper usingX-Admin-Keyheader +hmac.compare_digestwithRC_ADMIN_KEYenv var. Returns401 Unauthorizedfor invalid/missing keys.Bounty