Repository navigation
Accept empty transport bodies for agent grant revocation - #66
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
OpenRouter review posted ( |
There was a problem hiding this comment.
OpenRouter pull-request review
Verdict: issues
Scope: full-pr (full-pr)
Mode: initial
Commit: 674c98059e2ca92b49c1673a51078ca94f6c0224
Judge: openai/gpt-5.6-luna (repaired(canonical+4): source coverage preserved before publication cap)
Cost: $0.2225 (lanes $0.2205 + judge $0.0020)
Lanes
openai/gpt-6.1-sol: ok (0 finding(s), 36.1s, 163454+1091 tokens (128806 cached), 6 tool round(s), via Azure, $0.12)z-ai/glm-5.3-flash: ok (5 finding(s), 353.6s, 1323344+46251 tokens (1200384 cached), 28 tool round(s), via Wafer, $0.0990)
Findings
🟠 Issue 1 — 16-empty-chunk cap can reject a semantically empty chunked DELETE body
worker/src/agent-access-api.ts:60 · risk · identified by z-ai/glm-5.3-flash
A client that sends a Transfer-Encoding: chunked DELETE whose body consists of more than 16 zero-length chunks transports exactly zero bytes — HTTP-semantically an empty body — but requireEmptyBody throws 400 invalid_request once the 16-read budget is exhausted, so a legitimate revocation fails.
The ten-second absolute deadline (expiresAt plus the setTimeout boundary) already bounds an endless empty-chunk flood, so the read cap adds false rejections without adding a protection the deadline does not already provide; a bytes-based rule (reject any non-zero byte, bound by the deadline) would accept every empty encoding.
Evidence: the loop counts reader.read() calls, not bytes; endless-empty in agent-access-runtime.test.ts pins the 16 cap as intended behavior, and the deadline checks (performance.now() >= expiresAt, request.signal.aborted) already terminate the loop independently of the count. The PR description itself calls this "a finite empty-chunk budget".
Proof gap: I could not confirm whether the production transport (workerd's decoded chunked body stream) or the UI's fetch ever surfaces zero-length chunks individually — undici as a client buffers and would not. If no real transport emits distinct zero-length chunks, the scenario is only reachable from hand-built streams; the finding stands as a semantic gap in the guard, not an observed production failure.
🔵 Issue 2 — Body-read deadline is expressed as two independent hard-coded 10_000 literals
worker/src/agent-access-api.ts:31 · nit · identified by z-ai/glm-5.3-flash
If a future edit changes only one of the two 10_000 literals (expiresAt = performance.now() + 10_000 on line 31 and setTimeout(onAbort, 10_000) on line 50), the wall-clock deadline and the abort/timer boundary diverge, and the effective bound becomes the larger of the two with confusing partial behavior.
The neighboring readJson in api-auth.ts threads a single timeoutMs value into both the expiresAt computation and the setTimeout, which is the established pattern this helper mirrors; a local const timeoutMs = 10_000 (or a shared constant reused with readJson's timeoutMs: 10_000 call sites) would remove the drift risk.
🔵 Issue 3 — Comment on the boundary catch misdescribes its purpose
worker/src/agent-access-api.ts:54 · nit · identified by z-ai/glm-5.3-flash
// Also observe an already-aborted boundary if header validation fails first. sits above void boundary.catch(() => {});.
The actual purpose of that statement is to suppress a potential unhandled promise rejection if boundary rejects (timer, abort) after the loop has already returned or thrown — the boundary is not "already-aborted" at that point, and the catch is not what observes an abort. A reader reconciling the comment with the code has to reverse-engineer the real reason; a comment like "the boundary may still reject after this function exits; keep its rejection handled" would match the mechanism.
🔵 Issue 4 — Mid-reauthentication block duplicated between the DELETE branch and the consent POST path
worker/src/agent-access-api.ts:152 · nit · identified by z-ai/glm-5.3-flash
The new grant DELETE branch (lines ~152–169) is a near-verbatim copy of the consent POST path's post-body re-check (lines ~231–237): sameBrowserHeaders() → requireAgentBrowserContext(request, options, true) → sameBrowserHeaders() → compare rawSessionId and principalId → throw 403 'browser_credential_changed'.
The same re-check protocol now lives in three places in this file (initial derivation, DELETE mid-check, approve mid-check) plus the final check. If the protocol ever gains a field (for example also comparing the CSRF token or extending credentialHeaders), each copy must be updated in lockstep or the two mutation routes diverge in what they accept.
A small local helper taking the captured sessionId/principalId and returning the fresh context would collapse the duplication.
🔵 Issue 5 — Body-deadline documentation not extended to the new empty-DELETE revocation read
docs/KNOWLEDGE_COMPOSITION.md:254 · nit · identified by z-ai/glm-5.3-flash
docs/KNOWLEDGE_COMPOSITION.md (lines 254–258) enumerates exactly which transports carry the ten-second total body-read deadline: "Host-owned JSON POST bodies for portal reads, staff commands, agent test reports and consent approvals", with the 408 request_timeout + cancel + "starts no … command" guarantees.
This PR adds a fourth bounded body read — the empty DELETE body on /api/agent-access/grants/{id}, with the same 408/cancel/no-grant-read-or-commit behavior pinned by the new freshness tests — but the paragraph is not updated to include it, so the composition doc now under-describes the route's actual bounding behavior.
There was a problem hiding this comment.
OpenRouter pull-request review
Verdict: clean
Scope: latest-commit (commit-range)
Mode: verify
Commit: e70bc7cf9bc15f81463ef7f177f6d2e7331b0aa2
Judge: openai/gpt-5.6-luna
Cost: $0.0655 (lanes $0.0654 + judge $0.0001)
Lanes
openai/gpt-6.1-sol: ok (0 finding(s), 20.1s, 50524+676 tokens (32728 cached), 3 tool round(s), via Azure, $0.0600)z-ai/glm-5.3-flash: ok (0 finding(s), 29.3s, 54494+3188 tokens (30720 cached), 4 tool round(s), via Venice, $0.0054)
Round 2 resolution
- ✅
r1-1fixed correctly — 16-empty-chunk cap can reject a semantically empty chunked DELETE body:requireEmptyBodyno longer rejects after 16 empty reads. It continues until EOF, rejecting nonzero bytes and enforcing the absolute ten-second deadline and abort boundary. Every 16 empty reads now yields through a timer so immediately resolved reads cannot starve deadline or cancellation callbacks.
The updated tests cover successful revocation after 33 empty chunks, including invalidation of ac…
- 4 nit finding(s) from earlier rounds retired (severity floor for follow-up rounds is
risk). - Open findings after this round: 0 (0 bug-severity).
No structured findings from the successful lane(s).
|
r1-5 is fixed in e70bc7c. The current endpoint paragraph in docs/KNOWLEDGE_COMPOSITION.md documents empty-body grant revocation, cooperative empty-chunk yielding, the ten-second deadline and cancellation, and fresh authorization before the grant mutation. |
Changes
Validation
674c980commit passed the whole local suite on both Node versions, with 1,323 ordinary tests, 155 Native D1 tests and two benchmarks each. The final revision's configured full CI and OpenRouter review must pass before merge.The live Codex acceptance workflow reached accepted KB evidence, then its grant-revocation action returned an error. The empty-body case is reproduced locally. Live revocation and the subsequent old-credential rejection will be verified after deployment.