Repository navigation
feat(daemon,proxy): serve checked RPC that refuses protocol skew before dispatch - #5144
Conversation
…re dispatch POST /rpc/checked takes the same auth, body and answer as /rpc. After authentication, the daemon and the proxy compare the mandatory x-agent-device-rpc-protocol header with their own protocol before they decode anything that protocol defines, and refuse with 409 plus a typed x-agent-device-refusal header. The proxy admits both routes through one path, checks its own protocol, and forwards to the daemon's checked route. /health advertises checked-rpc. Additive: no protocol bump. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Size Report
Startup median (7 runs, lower is better):
|
There was a problem hiding this comment.
All reported issues were addressed across 10 files
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Apex Sentinel: 2 new findings on 861ac01. The verdict and the full list are in the summary comment.
…protocol refusal The daemon now runs a checked call through the /rpc flow and answers the protocol refusal after the auth hook, tenant-trust and token gates, with the same inputs. A call this build cannot decode is refused with no version. The proxy authenticates, then checks the protocol, then the envelope. Refusal errors are built by their owners; contracts keep data, so daemon-http.ts gains no eager kernel edge. The unreachable script-artifacts refusal is gone: every checked-rpc daemon serves script artifacts. checked-rpc joins DAEMON_CAPABILITIES. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This comment has been minimized.
This comment has been minimized.
|
At 8efd3fb, the new checked route has documentation and request handling problems to fix before merge. The public docs now give a wrong closed list of proxy routes. README.md:10 and remote-proxy.md:331 omit A second independent pass found that the daemon can answer a checked request before it verifies the configured transport credential (http-server.ts:334). With a wrong bearer credential, a protocol mismatch gets a 409, an unknown method gets a 404, and invalid params or a missing command name also return early. Can every checked request verify the transport credential before it compares the protocol or decodes method params, so that a wrong credential always gets 401? Credential extraction should not depend on the method decoder, and legacy A second independent pass found that a checked request with skew can get the protocol 409 when the auth hook never completes successfully (http-server.ts:383). This covers a hook that throws or rejects its promise, and requests that never reach the hook because of the envelope, params, command name, or tracking registration. Can the protocol refusal be sent only after the hook and tenant checks succeed, with a safe non-protocol rejection in every other case? A second independent pass found that the daemon echoes an unchecked request A second independent pass found the same echo in the proxy (checked-rpc-admission.ts:28): the raw A second independent pass found that a recognized upstream protocol 409 is forwarded with its whole body and copied header values (daemon-proxy.ts:393). An internal URL in the error body or in A second independent pass found that the outbound checked request follows redirects by default (daemon-proxy.ts:385). A same-origin 307 or 308 to A second independent pass found that a checked call that will be refused still reserves the caller's Not blocking: take or leave a shared refusal builder in contracts for the near-identical daemon and proxy code, a fix to the ADR claim that proxy authentication does not decode the body (the default reads None of the earlier review threads still apply, so they can be resolved: capability is now kept; the hook now sees the real request; the ADR section is now placed correctly; the envelope check now follows auth and protocol; the refusal now follows the Every CI job except Body rules passed at this commit. Body rules was cancelled during toolchain setup, before the body check ran, so it has no result. That check reads only the PR body, so the cancellation is likely unrelated to the code. It failed two rules on an earlier commit, so the current body has not been shown to pass. Not verified here: local tests and gates were not run. No mutation run confirmed that each ordering test fails if the protocol refusal moves before the hook, although the new route tests should fail on the base with a 404. A #5145 client against a proxy in front of an older daemon was not checked end to end; that behavior belongs to the client PR. Before merge, fix the route lists and tenant method rule, address the questions above, and get a completed Body rules run. |
…usals from local values - The daemon checks a checked call's transport credential, read from the headers or the JSON frame, before it compares the protocol or decodes the method, so a wrong credential always gets 401. - The protocol refusal comes only after the auth hook, tenant and token gates pass; every earlier failure, a throwing hook included, gets the ordinary /rpc rejection. A refused call never reserves its request id. - Refusals echo only a bounded id, and are built by one data-only builder in contracts. The proxy rebuilds an upstream protocol refusal from validated, bounded values and never copies its body or headers. - The proxy never follows a redirect on the checked route; custom transports must honor request.redirect. - Proxy README and remote-proxy docs name /rpc/checked, its prefixed form and the protocol header; the ADR states the new ordering. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks. Fixed in 7be2a52; each behavioural fix has a test that fails without it (checked by mutation).
Non-blocking: I took the shared builder as a data-only |
This comment has been minimized.
This comment has been minimized.
|
At 7be2a52, one diagnostic field in the proxy's rebuilt protocol 409 is still unbounded. Seven of the eight fixes requested earlier are in place. The request to bound the upstream refusal's diagnostic values is only partly met. A second independent pass found that the version check limits the suffix but not the three numeric parts. On either checked proxy route, an authenticated, protocol-matched request can reach an upstream that returns a None of these review threads still apply, so they can be resolved: capability is listed; hook gets the decoded request; ADR text is placed correctly; envelope check follows auth and protocol; early token check exposes no version; comment and docs are updated; error reason wording is fixed; refusal parameter is typed narrowly; the named ADR text was rewritten; the code behind it had already changed. All 22 CI checks pass at this commit, including Body rules. Not verified here: local tests and mutation runs were not run. That each new test fails without its fix was judged from the test bodies. Rejection of redirects by the default fetch rests on Fetch semantics and the PR's real-server 307 test. A #5145 client against a proxy in front of an older daemon was not checked end to end; that belongs to the client PR. Before merge, bound the version field and add its test. |
…x check A checked refusal's version is capped at the 64 characters the /health reader allows before the syntax test, so a version of many digits never reaches the proxy's rebuilt 409; the refusal keeps its reason without the diagnostic fields. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Fixed in 1633e10. |
Apex Sentinel · ✅ Approve · review of
|
| Command | What it does |
|---|---|
@apex-sentinel-staging note <context> |
Adds context; Sentinel re-checks the cited code |
@apex-sentinel-staging pivot <why> |
Says the finding is wrong; Sentinel re-checks the cited code |
@apex-sentinel-staging like |
Marks the finding as useful |
@apex-sentinel-staging dislike <why> |
Marks it as not useful, so it is not raised again |
On this conversation, comment @apex-sentinel-staging review to run a full review once again.
|
No blocking problems were found in 1633e10. The version length problem from the review of 7be2a52 is fixed: the whole version string is now capped at 64 characters before the syntax check. A proxy test covers this through the proxy route: an oversized version keeps the protocol 409 and drops the diagnostic fields. These earlier threads no longer apply and can be resolved, since the changes since 7be2a52 leave their fixes in place: capability listed, hook gets decoded request, ADR text placed, envelope check ordered after auth and protocol, early token check exposes no version, comment and docs updated, error reason wording fixed, refusal parameter typed narrowly, ADR text rewritten, and code already changed at 7be2a52. CI is green: all 22 checks pass at 1633e10, including the wire compatibility ledger and the new proxy test. Not verified here: the new test and the mutation run reported for it were not executed locally. That the test fails without the cap is judged from the version pattern, the 64 KiB read limit and the test body. The thread texts were not re-read; their status rests on the check at 7be2a52 and on the first four commits being unchanged. Nothing further is needed from this review before merge. |
Summary
Adds
POST /rpc/checked(also/agent-device/rpc/checked) on the daemon and proxy so the server refuses protocol skew before dispatch, in place of the client's/healthprobe. Replaces closed #5134. The client opt-in is #5145./rpc. Thex-agent-device-rpc-protocolheader is mandatory.x-agent-device-refusal(protocol-missing,protocol-mismatch, orupstream-protocol-mismatchthrough a proxy)./healthandDAEMON_CAPABILITIESlistchecked-rpc. Additive ledger entries, no protocol bump. ADR 0006 amended.Security
params.token) before it reads the protocol or method: a wrong credential always gets 401./rpcrejection. A refused call reserves no request id.Before / after
No observable change until a client calls the route. Released servers answer it with 404 before dispatch.
Validation
Head 1633e10. Ordering, id, reservation, rebuild and redirect tests fail without their fixes (checked by mutation). Proxy and daemon checked tests,
test/wire-compat, eager-closure budgets, the layering scan andfallow auditpass locally. CI pending.🤖 Generated with Claude Code