Skip to content

Bug: Main server attest_debug endpoint allows bypass when RC_ADMIN_KEY not set #5042

@508704820

Description

@508704820

Bug: attest_debug admin check bypassed when RC_ADMIN_KEY not configured

Severity: MEDIUM

Description

node/rustchain_v2_integrated_v2.2.1_rip200.py has an admin check that can be bypassed:

ADMIN_KEY = os.getenv("RC_ADMIN_KEY")  # Returns None if not set

@app.route('/ops/attest/debug', methods=['POST'])
def attest_debug():
    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 ""):  # None or "" → ""
        return error

When RC_ADMIN_KEY is not set:

  • ADMIN_KEY = None
  • ADMIN_KEY or "" = ""
  • admin_key (no header sent) = ""
  • hmac.compare_digest("", "") = True — authentication bypassed!

Impact

  1. Debug endpoint accessible without admin key when env var not set
  2. Exposes internal config, MAC hashes, and miner enrollment data
  3. Same class as Bug: machine_passport_api admin endpoints open when ADMIN_KEY unset #4878, Bug: Memory API /clear endpoint lacks authentication #4880, Bug: Webhook auth skips signature verification when WEBHOOK_SECRET not configured #4995 — default-allow auth pattern

Fix

Add explicit check for ADMIN_KEY being set:

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"}), 401

Wallet: RTC9d7caca3039130d3b26d41f7343d8f4ef4592360

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions