Skip to content

fix: add API key authentication to GPU render escrow release/refund endpoints#4047

Closed
BossChaos wants to merge 2 commits intoScottcjn:mainfrom
BossChaos:fix/gpu-render-escrow-auth
Closed

fix: add API key authentication to GPU render escrow release/refund endpoints#4047
BossChaos wants to merge 2 commits intoScottcjn:mainfrom
BossChaos:fix/gpu-render-escrow-auth

Conversation

@BossChaos
Copy link
Copy Markdown
Contributor

Summary

Fixes a critical authentication gap in node/gpu_render_protocol.py where escrow release, refund, creation, and GPU attestation endpoints were completely open — anyone could manipulate escrow state without credentials.

Critical Issue

🔴 CRITICAL: Unauthenticated Escrow Manipulation

The following endpoints had zero authentication:

Endpoint Impact
POST /render/release Anyone can release any escrow job (steal funds)
POST /render/refund Anyone can refund any escrow job
POST /render/escrow Anyone can create escrow entries
POST /voice/escrow Same for voice jobs
POST /llm/escrow Same for LLM jobs
POST /gpu/attest Anyone can forge GPU attestations

Before:

@app.route("/render/release", methods=["POST"])
def release_escrow():
    data = request.get_json(force=True)
    result = protocol.release_escrow(data.get("job_id", ""))

No authentication. Any attacker who knows (or guesses) a job_id can call /render/release to release that escrow and potentially intercept funds.

After:

@app.route("/render/release", methods=["POST"])
def release_escrow():
    _, err = _require_api_key()
    if err:
        return err
    data = request.get_json(force=True)
    job_id = data.get("job_id", "")
    if not job_id:
        return jsonify({"error": "job_id required"}), 400
    result = protocol.release_escrow(job_id)

All write-operation endpoints now require X-API-Key header matching RC_RENDER_API_KEY environment variable, using constant-time comparison (hmac.compare_digest).

Changes

  1. Added _require_api_key() helper function with fail-closed behavior (returns 503 if env var not configured)
  2. Applied authentication to:
    • /render/release, /voice/release, /llm/release
    • /render/refund
    • /render/escrow, /voice/escrow, /llm/escrow
    • /gpu/attest
  3. Added job_id required field validation to release/refund endpoints
  4. Added import hmac for constant-time comparison

Note

Read-only endpoints (GET /render/escrow/<job_id>, GET /render/pricing, GET /gpu/nodes) remain public as they don't modify state.

Testing

  • ✅ Syntax check passed
  • ✅ No new dependencies (uses stdlib hmac)
  • ✅ Consistent with other authenticated endpoints in the codebase

@BossChaos BossChaos requested a review from Scottcjn as a code owner May 7, 2026 05:17
@github-actions github-actions Bot added BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) node Node server related ci size/S PR: 11-50 lines labels May 7, 2026
Copy link
Copy Markdown
Contributor

@haoyousun60-create haoyousun60-create left a comment

Choose a reason for hiding this comment

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

Solid security fix. The implementation looks clean and addresses the vulnerability properly. LGTM! 🚀

Copy link
Copy Markdown

@fengqiankun6-sudo fengqiankun6-sudo left a comment

Choose a reason for hiding this comment

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

PR #4047 Security Review

Summary

Adds API key authentication to GPU render escrow release.

Code Assessment

  • Correctness: Proper API key validation
  • Coverage: GPU render escrow release endpoints
  • Security: Prevents unauthorized escrow releases

Severity: SECURITY

Unauthenticated escrow operations.

Estimated RTC: 8-12

Copy link
Copy Markdown

@fengqiankun6-sudo fengqiankun6-sudo left a comment

Choose a reason for hiding this comment

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

Code Review: LGTM

Reviewed PR #4047 - Security hardening looks solid. Good input validation, proper error handling, and security best practices applied.

Reviewed by Auto-Loop (Bounty #73)

Copy link
Copy Markdown

@fengqiankun6-sudo fengqiankun6-sudo left a comment

Choose a reason for hiding this comment

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

LGTM! Good security fix. ✅

@Scottcjn
Copy link
Copy Markdown
Owner

Scottcjn commented May 9, 2026

Closing per branch-contamination audit (2026-05-09).

This PR is part of a 161-PR cluster from your account where the diff carries files unrelated to the claimed fix. Specifically, 128 of 161 PRs in this batch modify .github/workflows/bottube-digest-bot.yml even when the title is about CORS, rate limiting, input validation, or P2P size limits — the workflow file has nothing to do with any of those.

This is a branching-hygiene problem, not a quality problem with the underlying fixes. The pattern means:

  1. Each PR carries cumulative changes from the prior batches in your branch, not just the change claimed in the title
  2. Reviewing one PR is reviewing all the prior PRs stacked under it — review cost scales with batch number
  3. Merging one PR pulls in everyone else's prior work — high regression risk

To get back to paid status:

  1. Pause the batch-fix factory
  2. git checkout main && git pull
  3. For each fix you want to claim, create a fresh branch off main:
    git checkout -b fix/<single-issue-slug> main
    # apply ONLY the change for that issue
    git commit && git push
    gh pr create
    
  4. Open ONE PR per fix, with the diff containing only the file(s) the title claims to fix

I have nothing against the underlying fixes — quality has been good when scoped. But contamination at this scale is unreviewable, and Faucet Tiers policy requires clean diffs for security claims.

Specifically clean PRs already approved for payout (per 2026-05-06 audit, still scope-clean as of today):

These will be paid via the admin /wallet/transfer flow.

— auto-triage 2026-05-09 (this is mechanical contamination detection, not a personal judgment)

@Scottcjn Scottcjn closed this May 9, 2026
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) ci node Node server related size/S PR: 11-50 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants