Repository navigation
fix(FIX-1955): a resource's secret fields never leave the server, debug routes included - #3268
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 3 Skipped Deployments
|
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: fff52bde-c317-4a04-a237-44693b036af5) |
|
@codex review |
Codex Review SummaryThis 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. |
Second look + architecture pass (FIX-1955)Verdict: the approach is right and proportionate. A declarative 1. Leak audit (the "parts worth reviewing" question)I traced every
2. Six call sites each remember to call
|
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: 7e0999a4-72f8-46e1-bb59-a6604c1bda82) |
There was a problem hiding this comment.
Simplify review (FIX-1955)
Verdict: The feature shape is the right one — a definition-time secret list plus stripping on egress is simpler and clearer than bolting redaction onto debug-only routes, using a generic path-redaction library (fast-redact, etc.), or Zod transforms that would also shrink what blocks see on the server. Reusing the existing private omit() beside exclude keeps one omission implementation. I’m approving because the surfaces that matter today are covered and the integration tests (including the workforce router path) make the security intent hard to regress accidentally.
The main complexity cost is not the API; it’s enforcement spread. omitSecretFields is wired in five engine places (route-utils, resource-routes/applyClientData, resource-registry live deltas, debug-snapshot ×2). Each pairing is only two lines, but every new “state leaves the server” path must remember the dance. That’s the classic “went far enough to be safe, one step short of being simple.”
Cleaner approach (optional follow-up, not a merge blocker)
Export a single core helper, e.g. resolveClientData(config, state) → resolveClientProjection(client, omitSecretFields(config, state)), and make that the only supported way to build client-facing state. Engine call sites (including liveProjection and debug computeClientView) would call it instead of open-coding the pair. Benefits:
- One place to document the contract (“secrets never reach projection”).
computeClientViewstops depending on callers having already redactedstate.- Slightly easier to fold secret keys into
pick/excludein one pass later (todayexpose+secretdoes omit then pick — fine for MCP-sized state).
I would not hide omission inside resolveClientProjection(client, state) alone — it needs the resource config’s secret, so a thin wrapper is the right seam.
Smaller notes (unsure = treat as suggestions)
- Projected collections:
defineProjectedResourceCollectionstill validates client projection withoutsecreton the config type. If projected rows can ever hold credentials, this is a gap; if not, a one-line doc call-out avoids surprise. - Validation parity: Unknown
secretkeys are skipped whenintrospectStateKeysreturnsundefined(same asexpose). For secrets I’d consider requiring a plainZodObjectwhensecretis non-empty — not sure that’s worth the inconsistency cost. - Tests:
secret-resource-fields.test.tsheader promises a live-delta check; that lives inresource-registry.spec.tsinstead — align the comment or add one case here. - Core unit tests: Behavior is pinned via engine integration tests; a couple of cases in
client-projection.test.tswould keep the helper honest if engine imports drift. - Docs/types: Documented honestly that
ClientDataOfstill lists secret fields under identity/exclude— runtime omit is the real guarantee; type-levelOmitwould be a larger follow-up.
What I would not change
- Third-party redaction libs for a fixed key list at definition time.
- Redacting
content(correctly out of scope; contentTemplate leakage is a separate author concern). - Duplicating the workforce debug test entirely — the real-router proof is worth keeping even though engine tests overlap.
Nice, focused product fix with tests that match the threat model.
Sent by Cursor Automation: Review For Best Approach
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: fbcdb5fb-a89e-43a7-b019-0307124c4476) |
There was a problem hiding this comment.
Code Snob. I tried one helper for the projection reads. It tied. No POC.
omitSecretFields is the strip. The two debug builders call it, then computeClientView on that state. applyClientData is already omit-then-project for list, get, and search. The snapshot and the live delta each do that pair once, in files that do not import the route module.
I folded those four pairs into projectClientState and deleted applyClientData. The helper is 11 lines, with a cast because omit returns JsonObject. The call sites lose 15. Against this head (those call sites are unchanged since db7c2f941) that is +21/−26. A new export for five lines ties. Debug still calls omitSecretFields.
The line above secret: ["value"] repeats the header. One line. The new omitSecretFields cases pin the same-object return; the drop is already the engine reads.
Left as recorded: secret stays its own list.
Sent by Cursor Automation: Code Snob
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: db7c2f9418
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: 117d82f3-8e1a-4407-a0e7-d2e37ed03baf) |
|
Architect: not approving yet. The Codex P1 on scope-level |
|
Architect: not approving yet. An open Codex P1 remains on scope |
|
Architect: not approving yet — Codex P1 on scope-derived projections is still unresolved ( |
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: c8c3b985-7fa4-4149-b6ab-5cc21485ebae) |
…e server, debug routes included (FIX-1955) Resources and collections take a `secret` list of state fields. Every read the engine serves omits them: the client snapshot, the list-state and get-state routes, live deltas, and the debug routes, which otherwise return full state. Workforce's mcp-credentials collection declares `value` secret, so a stored MCP key no longer comes back from /debug/resources*. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0149AEso8yp91qXPZtLjKe6z
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0149AEso8yp91qXPZtLjKe6z
… redacted state (FIX-1955) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0149AEso8yp91qXPZtLjKe6z
…om its result; shared cells must agree on secret fields (FIX-1955) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0149AEso8yp91qXPZtLjKe6z
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0149AEso8yp91qXPZtLjKe6z
f84e4b7 to
95e15c0
Compare
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: 141dec1a-57bd-4a97-8731-6028544be4b0) |


Requested by Jake · project thread
The problem
With debug endpoints on (
fsdev dev, the Shift Manager Lab),GET /api/flows/sessions/:id/debug/resources/mcpCredentials/itemsreturned a user's stored MCP key in full. The debug routes skipclient.*shaping by design, so theexpose: ["setAt"]on the key collection did not cover them, and nothing else could.What this does
defineResourceanddefineResourceCollectiontake a new top-levelsecretlist of state fields. A name not on the schema, or oneclient.exposealso names, throws at definition time. NewresolveClientData(config, state)runs the client projection on the full state and drops anysecretfield from the top level of its result.resolveClientData, so aclient.datafunction sees the full state and can derive from a secret (keyTail: s.value.slice(-4)) but cannot return one. The flow registry refuses two declarations of one shared cell that mark different secret fields (secret-mismatch). The engine learns only the generic marker; nothing Workforce-specific lands in L1.mcp-credentials/*declaressecret: ["value"].Before: a debug read of a stored key returned
{ value: "<key>", setAt }. After: it returns{ setAt }.What's asked of you
One call on an open review thread: Codex asks that scope-level
client.derivedprojections also be handed secret-stripped resources. I recommend not doing that:derivedis author-written projection code likeclient.data, a leak needs an explicit read-and-return, and stripping would break derivations likehasKey. If you disagree, it's a follow-up.This is stacked on #3261 (the key store it protects lives there); it retargets to
mainwhen #3261 merges.Parts worth reviewing closely
packages/core/src/helpers/client-projection.ts(resolveClientData) and its engine call sites. Is any other server-leaving state read not going through it oromitSecretFields? If so, a secret leaks through that path.packages/engine/src/registry/flow-registry.ts,checkResourcePair. Does every shared-cell comparison carry the secret list?secretcovers state, not content (acontentTemplatethat interpolates a secret field renders it). The derivedClientDataOftype still lists a secret field under the identity orexcludeprojection, so pairsecretwithexpose. Model resource tools read through the server-side handle and are not affected.Fixes FIX-1955 · Found in #3261 (FIX-1905) · Bug route, no spec.
Verification
packages/engine/test/secret-resource-fields.test.ts(10) and a live-delta case intest/context/resource-registry.spec.ts. Red states: with the engine change stashed, the debug tree, debug items, snapshot, list/get-state and live-delta cases fail; on the previous head, theclient.dataderivation case (throws ons.value) and the shared-cell refusal case fail. All pass now. Each read test also asserts the non-secret field arrives and the store holds the key.packages/workforce/test/mcp-credentials-debug-read.test.ts: the real collection through the real router's debug item route. Withoutsecret: ["value"]it fails with the key in the body; with it, it passes.coordinator-flow.ts,delegated-post.ts) that are identical with this change stashed.apps/docsbuild exit 0. Changeset check passes.docs-writer, reviewed bydocs-editor(all findings applied).Changeset: core, engine, workforce patch.
🤖 Generated with Claude Code
https://claude.ai/code/session_0149AEso8yp91qXPZtLjKe6z
Note
Medium Risk
Changes how all outbound resource state is shaped and closes a debug-endpoint credential leak; misconfigured or bypassed read paths could still expose secrets, but coverage is broad and regression-tested.
Overview
Adds a top-level
secretlist ondefineResource/defineResourceCollectionso named state fields never appear in any server response path—client snapshots, list/get-state,livedeltas, and debug endpoints (which previously returned full state regardless ofclient.expose).Core validates
secretagainst the schema and blocks overlap withclient.expose, and introducesresolveClientData(projection on full state, then strip secrets) plusomitSecretFieldsfor raw debug payloads.client.datacan still derive from secrets; returning a secret key in the result is stripped.Engine switches those read paths from
resolveClientProjectiontoresolveClientDataand omits secrets in debug snapshots; the flow registry rejects shared storage cells whose flows disagree onsecret(secret-mismatch).Workforce marks MCP credential
valueas secret (FIX-1955). Docs and tests cover the contract and limits (state only, not content; scopeclient.derivedunchanged).Reviewed by Cursor Bugbot for commit 95e15c0. Configure here.