Skip to content

[Bug] bridge_api.py: update-external endpoint timing-unsafe comparison + unauthenticated when RC_BRIDGE_API_KEY unset #3225

@haoyousun60-create

Description

@haoyousun60-create

Security Audit Finding

Severity: Medium
File: node/bridge_api.py:788-792
Issue: The /api/bridge/update-external endpoint (bridge service callback) uses != for API key comparison instead of hmac.compare_digest, and is completely unauthenticated when RC_BRIDGE_API_KEY is not set.

Code:

api_key = request.headers.get("X-API-Key", "")
expected_key = os.environ.get("RC_BRIDGE_API_KEY", "")
if expected_key and api_key != expected_key:  # Timing-unsafe + bypass when unset
    return jsonify({"error": "Unauthorized"}), 401

Impact:

  • Timing attack on API key comparison
  • When RC_BRIDGE_API_KEY is not set, endpoint is completely open
  • Attacker can forge external confirmation data (fake confirmations, fake tx hashes)
  • Could mark bridge transfers as "completed" without actual external confirmation

Fix:

expected_key = os.environ.get("RC_BRIDGE_API_KEY", "")
if not expected_key or not hmac.compare_digest(api_key, expected_key):
    return jsonify({"error": "Unauthorized"}), 401

Wallet: RTC4642c5ee8467f61ed91b5775b0eeba984dd776ba

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