Skip to content

fix(mcp,sharing): redact project keys, session ids and branch names in the payload - #1337

Merged
iamtoruk merged 2 commits into
getagentseal:mainfrom
ozymandiashh:fix/1325-1321-redact-payload-identities
Sep 13, 2026
Merged

iamtoruk merged 2 commits into
getagentseal:mainfrom
ozymandiashh:fix/1325-1321-redact-payload-identities

Conversation

@ozymandiashh

Copy link
Copy Markdown
Collaborator

Two identity fields were riding along in the menubar payload and coming out the other side of the redaction passes untouched.

current.topSessions[].projectKey — added with the drill-through rows in #1316 — is the raw sessions-list row key: a dash-encoded absolute working directory like -Users-me-Projects-acme. redactProjectNames rebuilt each row with a spread and replaced only project, so a client calling get_usage with include_project_names: false still got the working directory of every top session sitting next to the pseudonymized name. The same spread carried the drill-through sessionId through, on those rows and on topProjects[].sessionDetails — where the pass deliberately blanks date, and a Codex session id has the rollout timestamp inside it.

current.byBranch[].branch — the per-branch rows from #788 — is the raw git branch, and neither sanitizeForSharing nor redactProjectNames touched the block, so a branch like exp/extraction-arms reached a shared payload and an MCP client exactly as typed. Branch names carry ticket ids, customer names and codenames; they belong with the project names.

What changes:

  • MCP with include_project_names: false: projectKey is hashed with the same salted pseudonym as topProjects[].id (same kind of value, same namespace, so one directory hashes to one pseudonym in both places), sessionId becomes session-xxxxxx, and each distinct branch becomes a stable branch-xxxxxx. Cost, calls and session counts are untouched. A null branch stays null — that row is unbranched spend, not a name. provider is left alone; it is claude/codex, not identity.
  • Sharing: the per-branch block is dropped from the payload, the same outcome the project and session rows already get.
  • include_project_names: true is unchanged: every name still comes through as recorded. The local menubar, the desktop app and the web dashboard read the unsanitized payload, so nothing changes for them; the app's branch lens is fed by its own CLI report over IPC, not by this block, and I checked that nothing in dash/, app/, mac/, windows/ or gnome/ reads payload.current.byBranch at all.

One trade-off I want a second opinion on: for sharing I strip the branch rows rather than pseudonymize them. Pseudonymized branches would tell a peer device nothing, stripping is what project and session rows get today, and no shared surface renders the block — but it does mean per-branch spend can never appear on a combined multi-device dashboard without revisiting this. If you'd rather keep the aggregates and lose only the name, reusing the MCP pseudonym is a one-liner — with the caveat that the pseudonym salt would then start leaving the device.

Verification: the new cases fail on main and pass here. Targeted run (tests/mcp-redact.test.ts, tests/sharing/sanitize.test.ts, tests/menubar-json.test.ts) is 53 passed across the three files (13 + 5 + 35); npx tsc --noEmit is clean; the full suite is 4087 passed / 10 failed, and each of those 10 is a CLI-subprocess test that timed out under parallel load — the seven affected files pass on their own with this branch applied (70/70). I also reverted the two source files with the new tests in place to confirm they fail for the right reason, then restored them.

One thing this PR does NOT fix, on purpose: current.pullRequests survives both passes verbatim, and PrRow carries the full PR url plus an owner/repo#123 label, so the repository owner and name reach a shared payload and a name-redacted MCP client. Same class of leak as #1321, arguably worse than a branch name. I'd rather file it separately than widen this PR.

Fixes #1325
Fixes #1321

redactProjectNames rebuilt every row with a spread and replaced only the
fields it knew about, so identities added to the payload later rode
through untouched with include_project_names: false:

- topSessions[].projectKey, the raw sessions-list row key, is a
  dash-encoded absolute working directory (-Users-<user>-Projects-<repo>).
  Hash it with the project pseudonym, the way topProjects[].id already is.
- topSessions[].sessionId and topProjects[].sessionDetails[].sessionId are
  the drill-through identity; a Codex id also carries the rollout
  timestamp this pass blanks out of `date`. Hash them as session-xxxxxx.
  provider stays: it is claude/codex, not identity.
- byBranch[].branch is the raw git branch, which encodes ticket ids,
  customer names and feature codenames. Give each distinct branch a
  stable branch-xxxxxx pseudonym and keep the row's numbers. A null
  branch stays null: that is unbranched spend, not a name.

The new pseudonyms are domain-separated inside the digest so a branch and
a project of the same name do not share a hash; the project pseudonym
itself is unchanged. redactSessionDetails now takes its type from the
payload instead of a hand-copied inline type that had drifted from it,
which is why the leak type-checked. include_project_names: true is
unchanged.

Refs getagentseal#1325, getagentseal#1321
sanitizeForSharing spread current and emptied only topProjects and
topSessions, so the per-branch rows added with the payload block went out
verbatim: a branch such as exp/extraction-arms reached a peer device as
typed. Branch names encode ticket ids, customer names and feature
codenames, so they get what project and session rows get and leave the
payload entirely. Pseudonymizing was the alternative, but a branch-a1b2c3
row means nothing on another device's dashboard, and no shared surface
reads the block today.

Refs getagentseal#1321, getagentseal#1325
@iamtoruk
iamtoruk merged commit fd8f05c into getagentseal:main Sep 13, 2026
20 checks passed
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.

mcp: current.topSessions[].projectKey survives redactProjectNames sharing: current.byBranch[].branch survives sanitizeForSharing and MCP redaction

2 participants