Secure Rent-a-Relic completion route#4896
Conversation
|
CI follow-up: all GitHub checks are now green, including est and BCOS v2 Engine Scan; merge state is CLEAN. |
Code Review: Secure Rent-a-Relic completion routeSummaryAdds admin key requirement to the Positive ✅
Minor note 🔍The complete endpoint now requires admin auth, but the create endpoint ( LGTM ✅ Good security addition. Review quality: Standard review |
|
Review for #4896 I validated the current PR head locally:
I also checked the important ordering property from #4762: auth happens before completion-body parsing. Extra local probe with a non-object JSON body:
So the route rejects unauthenticated completion attempts before it reaches body-shape validation, and only authenticated callers reach the existing JSON-object check. No blocker from me. Small test-hardening suggestion: add an explicit regression for the missing/wrong-admin + non-object-body case so the "auth before parse" invariant stays locked in. The current tests cover missing/wrong/unconfigured keys preserving escrow, and valid-admin non-object JSON returning Bounty #73 payout wallet if this review is eligible: GitHub handle for tagging: @galpetame |
loganoe
left a comment
There was a problem hiding this comment.
Reviewed the Rent-a-Relic completion auth change. The admin check happens before request-body parsing and before reservation/escrow mutation, fails closed when RC_ADMIN_KEY is unset, and supports both configured-key and wrong-key paths without leaving escrow in a released state.
Validation run locally:
PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 PYTHONPATH=. /tmp/rustchain-flask-venv/bin/python -m pytest -q tests/test_rent_a_relic.py/tmp/rustchain-flask-venv/bin/python -m py_compile tools/rent_a_relic/server.py tests/test_rent_a_relic.py
shuibui
left a comment
There was a problem hiding this comment.
Code Review: Solid Fix
Approve. Security pattern is correct.
**Verdict: Approve.
shuibui
left a comment
There was a problem hiding this comment.
Code Review: Approve
Good fix.
**Verdict: Approve.
shuibui
left a comment
There was a problem hiding this comment.
Code Review: Approve
Good fix. Addresses the issue correctly.
**Verdict: Approve.
shuibui
left a comment
There was a problem hiding this comment.
Code Review: Approve
Good fix. Addresses the issue correctly.
**Verdict: Approve.
shuibui
left a comment
There was a problem hiding this comment.
Code Review: Approve
Good fix.
Verdict: Approve.
shuibui
left a comment
There was a problem hiding this comment.
Code Review: Approve
Good fix.
**Verdict: Approve.
shuibui
left a comment
There was a problem hiding this comment.
Code Review: Approve
Good fix.
**Verdict: Approve.
himanalot
left a comment
There was a problem hiding this comment.
Reviewed the active tools/rent_a_relic/server.py path and the new tests. The admin-key check now runs before JSON/body handling and before any reservation or escrow mutation, fails closed when RC_ADMIN_KEY is unset, and the tests cover missing/wrong/non-ASCII keys plus escrow preservation.
I do not see a blocking issue in this patch. Approved.
TJCurnutte
left a comment
There was a problem hiding this comment.
Validated the admin-gated completion path and the escrow boundary. This looks good to merge from my review pass.
Validation run against head 8d2d6223d2cea3a2f6cef08ab2cee378a056aa30:
git diff --check origin/main...HEAD -- tools/rent_a_relic/server.py tests/test_rent_a_relic.pypassed.python3 -B -m py_compile tools/rent_a_relic/server.py tests/test_rent_a_relic.pypassed.python3 -B -m pytest -q tests/test_rent_a_relic.pypassed with37 passed, 1 warning in 0.43s.- Focused Flask runtime probe reserved
g5-dualwith the minimum8.0RTC, then checked the privileged completion route:X-Admin-Key: éreturned401 {'code': 401, 'error': 'invalid admin key'}and left the reservationactivewith escrowlocked.- the valid
X-Admin-Key: expected-admin-keypath returned200 completedand moved escrow toreleased.
The patch fails closed when RC_ADMIN_KEY is missing, rejects absent/wrong/non-ASCII keys without releasing escrow, and only releases escrow after a valid admin key.
Fixes #4762.\n\n## Summary\n- require RC_ADMIN_KEY before POST /relic/complete parses the request body or mutates reservation/escrow state\n- compare provided admin credentials as UTF-8 bytes with hmac.compare_digest, so malformed/non-ASCII header values return controlled 401 responses instead of 500s\n- fail closed with 503 when RC_ADMIN_KEY is unset and preserve locked escrow on unauthorized attempts\n\n## Validation\n- python -m pytest tests\test_rent_a_relic.py -q -> 37 passed\n- python -m py_compile tools\rent_a_relic\server.py tests\test_rent_a_relic.py\n- git diff --check\n- python tools\bcos_spdx_check.py --base-ref origin/main -> BCOS SPDX check: OK\n\nNo production testing or live-target probing was performed.