Skip to content

fix(transport): mutually authenticate relay HTTP requests - #122

Merged
OBenner merged 5 commits into
mainfrom
codex/1-mutual-auth
Nov 17, 2026
Merged

OBenner merged 5 commits into
mainfrom
codex/1-mutual-auth

Conversation

@OBenner

@OBenner OBenner commented Nov 17, 2026

Copy link
Copy Markdown
Owner

A loopback listener could copy the public health marker and capture a reusable role token. This change replaces relay HTTP Bearer authentication with per-project/role challenge, request and response MACs. Every client checks the relay before sending its business body; the relay consumes each verified challenge once before dispatch.

  • Derive purpose-separated HKDF/HMAC keys from existing credential material, bind exact request bytes/method/query and response status/body, and cap challenge lifetime, issuance and storage.
  • Thread trusted project/role context through CLI, MCP, supervisors and config generators. Reject legacy or mixed authentication; document the coordinated relay/client/config upgrade.
  • Update the threat model and rotation runbook: credential hashes are authentication-equivalent secrets. Active forwarding proxies can still observe plaintext; caller-chat and owning-user compromise boundaries remain unchanged.

Validation: full pnpm verify passed (111 files, 979 tests, build) on 3982337 after rebasing onto main 0d972bc, including error-stream cancellation. Subsequent documentation-only commits 7e59e45 and ffbf565 passed formatting and diff checks. The lead developer independently confirmed 111 files / 979 tests passing. Fixed vectors were independently calculated with Python hashlib/hmac. Conformance covers forged relay proofs, concurrent replay, tampering, rotation, restart, legacy incompatibility, redirects, issuance limits, audit hygiene and the forwarding-proxy limitation. No live deployment was performed.

Final security sign-off and architecture contract review approved implementation 7e59e45 on 2026-11-17. R1 is closed in this implementation; existing installations still require a coordinated upgrade. The final follow-up changes documentation status only.

Closes #1 after review and merge.

@OBenner

OBenner commented Nov 17, 2026

Copy link
Copy Markdown
Owner Author

Review (dev) — ACCEPT

The published diff (ffbf565) matches the reviewed implementation; the delta since my code review was verified docs-only (backlog/threat-model/transport-auth-v2 sign-off records, ffbf565). Independent full pnpm verify re-run on the published head: 111 files / 979 tests PASS; CI 5/5 on run 44040072328.

What was verified across two review passes:

  • Crypto core (auth-proof.ts): purpose-separated HKDF/HMAC keys derived from existing credential material; key id never exposes the verifier on the wire; length-prefixed framing with >65535 rejection; separate challenge/request/response MAC purposes; timingSafeEqual behind format validation; request binds transcript + uppercase method + verbatim target + exact body-hash; response binds request-hash + status + body-hash.
  • Server: Bearer rejected fail-closed (auth_v2_required; bearer_rejected, no dual-mode); challenge issuance rate-limited (100/s), capacity-bounded (1024), TTL 30 s, project checked before credential lookup, cap re-checked after the async lookup; challenge consumed atomically after MAC verification and before dispatch (no await between the final lookup and delete — concurrent replay dies as stale_challenge); response proofs carried via a WeakMap keyed on the response object; denial audit uses the fixed reason vocabulary.
  • Client: constructor requires trusted project/role context (fail-closed without it); health goes through the authenticated path; host versions and trusted context never come from network responses.
  • Conformance: forged relay proofs, concurrent replay, method/query/body/status tampering, rotation, restart, legacy incompatibility (both directions), redirects, issuance limits, audit hygiene, and the honest active-forwarder limitation — 26 dedicated tests, all green.

Full contour: dev code ACCEPT (this review and a final docs-delta pass), arch contract ACCEPT (452eb1d6, extended to the rebased head), security final sign-off APPROVE (312601dd — R1 closed). The coordinated-upgrade caveat is documented: relay, clients, and configs must move together; fail-loud incompatibility is the accepted behavior, covered by tests.

Passing to CTO for final.

@OBenner
OBenner merged commit a3c5f9b into main Nov 17, 2026
5 checks passed
@OBenner
OBenner deleted the codex/1-mutual-auth branch November 17, 2026 07:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[P1] Mutual relay authentication (per-project challenge) — R1 residual

1 participant