Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion node/rustchain_v2_integrated_v2.2.1_rip200.py
Original file line number Diff line number Diff line change
Expand Up @@ -6374,7 +6374,9 @@ def attest_debug():
"""Debug endpoint: show miner's enrollment eligibility"""
# SECURITY FIX 2026-02-15: Require admin key - exposes internal config + MAC hashes
admin_key = request.headers.get("X-Admin-Key", "") or request.headers.get("X-API-Key", "")
if not hmac.compare_digest(admin_key, ADMIN_KEY or ""):
if not ADMIN_KEY:
return jsonify({"error": "Admin key not configured"}), 503
if not hmac.compare_digest(admin_key, ADMIN_KEY):
return jsonify({"error": "Unauthorized - admin key required"}), 401
data = request.get_json()

Expand Down
10 changes: 10 additions & 0 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,13 @@ def test_pending_list_requires_admin(client):
"""Unauthenticated /pending/list should return 401."""
response = client.get('/pending/list?limit=abc')
assert response.status_code == 401


def test_attest_debug_fails_closed_when_admin_key_unconfigured(client, monkeypatch):
"""No configured admin key must not authenticate a missing header."""
monkeypatch.setattr(integrated_node, "ADMIN_KEY", None)

response = client.post('/ops/attest/debug', json={"miner": "miner-test"})

assert response.status_code == 503
assert response.get_json()["error"] == "Admin key not configured"
Loading