Skip to content

Remove Team Token PR2.2: Host-ref authority and validation - #795

Merged
josue-tech-94 merged 5 commits into
fix/host-rpc-admission-spec65from
fix/pr2-674-host-ref-validation
Sep 30, 2026
Merged

josue-tech-94 merged 5 commits into
fix/host-rpc-admission-spec65from
fix/pr2-674-host-ref-validation

Conversation

@josue-tech-94

@josue-tech-94 josue-tech-94 commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

PR2.2 implements the #674 / Specs 61–64 Host-ref authority and validation correction. Current head 0fbfc9a3aa00ea878f4c2698cb8f61a692ebcb27 is based on PR2.1 / PR #797 at c869d9f1a70752ff29cb3958790cd26e7e218a09. R2-M1 / RP795-001 is closed by a test-only correction that makes the W1 matrix reach W1. Exact-head CI 36486341459, Real PostgreSQL job 109144043026, CodeQL 36486341442 / Analyze 109144041940, and required GHAS 109149600035 passed. Round 3 returned No objection; GitHub still requires human approval. This PR is open and not landed, and #674 remains open.

Stack and lineage

Scope and contract

The change covers the exact 21 public /rpc/hosts/:hostRef... route registrations.

  • 674-A: signed hostRefs remains the ceiling, intersected with current live Control API Host authorization.
  • 674-B/W1: invalid captured bare Host refs return 400 after existing authentication, parsing, and exact local v2 binding gates, but before remote checkpoint/live Host work.
  • 674-C: existing denial/error precedence is preserved; valid inaccessible Host behavior remains unchanged.
  • Spec 64 / Spec 65 v2 order: authentication/parser → exact local binding → canonical route preflight → W1 → remote checkpoint → Host-message admission for messages or Host-RPC admission for in-scope non-message operations → live authorization → destination resolution → effect. PR2.1 supplies the admission prerequisite; this PR2.2 supplies W1 and composes the two without changing either authority.
  • Legacy routes retain authentication/scope/body precedence → canonical route preflight → W1 → applicable legacy Control API admission/authority → effect.
  • Exact v2 binding and no-downgrade remain mandatory. Specs 62 and 63 Host-message shared admission, request-local retry receipt, and derived same-Host host.wake(message_retry) behavior remain compatible.

Recovered linear exact-head security and compatibility status

Historical exact-head security status (superseded by current status above)

For the historical PR2.2 head bae2c298ba0bf524c8de706a5d83c2a48c613247:

  • Exact-head CI: run 36094982663 completed successfully; the relevant Control API, RPC Proxy, Desktop, External REST, shared-contracts, shell/hygiene, and remaining matrix jobs passed.
  • Exact-head Real PostgreSQL: job 107945232677 in run 36094982663 succeeded.
  • Exact-head CodeQL/GHAS: workflow-dispatch run 36095276777, Analyze job 107946140858, succeeded for fix/pr2-674-host-ref-validation at bae2c298ba0bf524c8de706a5d83c2a48c613247, category /language:javascript-typescript. Analysis 1837357434 is for refs/heads/fix/pr2-674-host-ref-validation at the same SHA. Required CodeQL check 107949765866 succeeded with zero annotations and “No new alerts in code changed by this pull request.” No current changed-code High/Critical alert was reported; no alerts were dismissed.
  • The prior-head check 107448846288 at ac2312d94e8e6fc11fd1bee259dbecb033473ad6 reported 30 High changed-code js/missing-rate-limiting annotations. Those instances were classified as base-equivalent R0 behavior and motivated the separate Spec 65 prerequisite. No alerts were dismissed in that earlier security-stop pass. That prior-head result is historical context only and does not establish the current head's security status.

Historical validation before linearization (superseded by current status above)

Local PR2.2 synchronization validation at bae2c298ba0bf524c8de706a5d83c2a48c613247:

  • RPC Proxy: 57 files / 767 tests passed; build passed.
  • Focused ordering review validation: 5 files / 112 tests passed.
  • Changed-file Prettier, git diff --check, and repository style rules passed. Style rules reported zero errors and one unrelated existing Desktop UI warning.
  • Code review: SAFE. Security review: SAFE. Bounded synchronization collateral: CLEAN.
  • Local Real PostgreSQL was unavailable because CONTROL_API_REAL_PG_ADMIN_URL is unset. Exact-head CI Real PostgreSQL passed and satisfies the required acceptance gate.
  • Exact-head CI 36094982663, Real PostgreSQL job 107945232677, CodeQL run/job 36095276777 / 107946140858, and required CodeQL check 107949765866 were successful at that historical head. Round 1 formal review returned No objection there; no GitHub review/approval was published.

Round 1 No objection was recorded on the prior reviewed head, before the current parent reconstruction and R2-M1 closure. No new formal review decision has been published for the current head. The corrected PR remains open for human review; #674 remains open until the accepted correction lands in dev. PR3 has not started.

@github-advanced-security github-advanced-security AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

CodeQL found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

@josue-tech-94 josue-tech-94 changed the title fix(rpc-proxy): validate Host refs before live Host work Remove Team Token PR2.2: Host-ref authority and validation Sep 25, 2026
@josue-tech-94
josue-tech-94 changed the base branch from feat/user-centric-runtime-access-paths to fix/host-rpc-admission-spec65 September 25, 2026 04:34
@josue-tech-94
josue-tech-94 force-pushed the fix/pr2-674-host-ref-validation branch from 2311cc2 to 7a7cf85 Compare September 25, 2026 19:28
@alfredolopez80

Copy link
Copy Markdown
Contributor

PR Review — Remove Team Token PR2.2: Host-ref authority and validation (#674 / Specs 61-64)

Review verdict

YES with conditions — no production blocker found; one confirmed test-quality defect weakens the W1 evidence.

Reviewed the complete diff at base 2bfe0b8 (PR797 head) → head 7a7cf85 (14 files, +794/−47) in disposable exact-head worktrees, with independent implementation/architecture and security lanes. The W1 grammar was additionally re-verified with a bounded pure-JS regex probe, including a trailing-newline hypothesis raised and retracted during review — JavaScript $ does not match before a final LF/CR (confirmed false positive; the anchors are correct).

Assessed against the Task 106 stack reviewer context as the top layer of the linear stack (334 → 594 → 797 → 795): the W1/Spec 64/65 composition this layer implements is coherent and matches the ordering the context asks reviewers to confirm. The activation-gate model is irrelevant to the one finding below (test quality, not gated behavior).

PR-introduced issue count

  • Blocker/Critical/High: 0
  • Medium: 1 (test quality)
  • Low: 0
  • Pre-existing: 0
  • Uncertain/unavailable: 0
  • Root-cause clusters: 1 (test evidence)

Finding

RP795-001 — Medium — rpc-proxy/src/__tests__/host-ref-validation.test.ts:89

The "comprehensive" invalid-Host matrix uses empty {} bodies for the approval approve/deny, model-selection, and rename routes. Those cases fail canonical preflight (which validates the bodies) before reaching W1, yet satisfy every matrix assertion (status 400 + no downstream effects). Removing W1 from those routes would keep the matrix green.

  • Invariant: a W1 regression test must reach W1 after all preceding gates pass, and distinguish W1's rejection from another 400.
  • Remedy: supply otherwise-valid bodies and assert {error: 'Invalid hostRef'}; pair each fixture with a valid-ref control proving preflight passes. (Rename has a separate valid-title W1 test; approvals/model still lack one.) Retain separate precedence tests with invalid bodies.

Verified clean

  • All 21 /rpc/hosts/:hostRef... registrations verified route-by-route: legacy and v2 gate order matches the Spec 64/65 composition; W1 sits after auth/parsing/exact-binding/preflight and before remote checkpoint/live Host work; the signed hostRefs ceiling is preserved and intersected with live Control API authorization; denial precedence (674-C) is unchanged; the v2 destination remains checkpoint-bound.
  • Grammar (HOST_REF_RE): 1–63 lowercase alnum/hyphen with alphanumeric ends; rejects uppercase, underscore, dot, Unicode, percent/slash encodings, control chars, surrounding/trailing whitespace, and >63 length; it inspects the raw captured segment while preflight/binding trim only their own copies. Pure-JS probe: host-a, host-a\n, host-a\r, bad\nhost → true/false/false/false.
  • Message retry receipts stay request-local; replacement preserves nonce/expiry; no state moved into shared wake coordination.
  • Security: no introduced security defect; exact binding and no-downgrade preserved on all gates.

Limitations and follow-ups

  • Static review only — "correct order" means source-inspected, not executed. Coverage gaps (not defects): no v2 W1-reaching matrix for all supported routes, and no end-to-end proxy→Control API ceiling-intersection test.
  • Minor architecture note: requireScope(...deferHostV2Checkpoint), validateHostRefAndAuthorize, requireValidHostRef, and the deferred binding helpers have no production callers in the inspected tree — drift risk, not a reachable defect. Prefer retaining one staged binding/preflight/W1/checkpoint mechanism.
  • Stack context: this layer composes cleanly with a future PR594 checkpoint fix, but as the top of the stack it cannot be approved for landing while the base is broken — PR594 carries three v2-chain blockers and PR797 a gateway blocker that affects active legacy traffic. Those belong to the parent PRs, not this diff; fixing this layer's test gap now is worthwhile so it does not need another rebase later.

josue-tech-94 and others added 5 commits September 29, 2026 20:37
Stable-ID: R27-M1

Class-check: /rpc/hosts/:hostRef public class -> 21 registrations -> one shared W1 validator
covers all 21; Desktop and internal Control API routes remain outside Spec 61.

Repro-test: mounted invalid_host assertions fail on 18/20 legacy-capable registrations at
730a6eb; both artifact registrations were
already-400 positive controls.
Separate the existing local v2 route binding from remote checkpoint execution

for the 21 Spec 61 Host-ref routes so shared W1 validation runs between

them. Non-Host v2 callers retain the original checkpoint path.

Class-check: requireScope calls in the 21 Host-ref registrations -> 21 sites -> all defer only the remote checkpoint until after shared W1; non-Host callers remain unchanged.

Repro-test: rpc-proxy/src/__tests__/host-ref-validation.test.ts rejects a producer-signed target with a whitespace Host ref before checkpoint I/O; RED at 490b0e3.
Class-check: w1PayloadRoutes in host-ref-validation.test.ts → 4 route classes
(approval approve/deny, model write, session rename). Valid bodies exercise W1;
valid-host controls cover all four. Malformed-body precedence remains separate
under Spec 61.

Repro-test: rpc-proxy/src/__tests__/host-ref-validation.test.ts:197
(fails at 6173730 when W1 is bypassed; each
assertion expects exact 400 but receives the downstream result).
@josue-tech-94
josue-tech-94 force-pushed the fix/pr2-674-host-ref-validation branch from 0fbfc9a to f52c984 Compare September 30, 2026 02:49
@josue-tech-94
josue-tech-94 merged commit f52c984 into dev Sep 30, 2026
43 checks passed
@josue-tech-94
josue-tech-94 deleted the fix/pr2-674-host-ref-validation branch September 30, 2026 03:06
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.

3 participants