GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — fix(providers): keep the MCP bearer out of ACP and Pi child environments by only21mil · Pull Request #17957 · pingdotgg/t3code Conversation
|
| Channel | Token in the env of the child and its subprocesses | Token in COREDUMP_ENVIRON |
Same user can read the token | Available for ACP stdio servers and Pi | Secret file to manage |
|---|---|---|---|---|---|
| Env var (main) | yes | yes | yes, from /proc/<pid>/environ |
yes | no |
Protocol or control channel (Codex JSON-RPC, Claude mcp_set_servers) |
no | no | from process memory only | no, see below | no |
0600 file, path in env (this PR) |
no, path only | no, path only | yes, from the file, by design | yes | yes: one per thread, removed after a clear and on session close |
mcpServers is a process spec (command, args, env). It has no header field, so the bridge can only receive the header through its environment, its argv or a file.--mode rpc has no command that hands an extension a value. The extension could request one with an extension_ui_request that the adapter answers over stdin, but that is new protocol on both sides, and the token would then travel in the RPC stream that native protocol logging records.acp-mcp-call depends on that. The change takes the token out of every copy of the environment and off disk once the session closes, not out of the user's reach. The triage's 0600 file has the same property.t3 acp-mcp-bridge started before a rotation keeps the old header in memory, as on main (ProviderSessionManager.ts:445: rotating afterwards cannot repair an already-configured process). Its MCP HTTP session was opened under that header. acp-mcp-call follows the rotation.T3_ACP_MCP_ENDPOINT and T3_ACP_MCP_AUTHORIZATION_FILE inherited by the server pass through when a session has no credential. At the spawn point the instance environment and the session overlay are already merged, so an inherited path looks like the current one. They hold an endpoint and a path, not a token. The server's own environment is not touched either, so children of other providers still pass on any legacy variable the server inherited, as on main.acp-mcp-call and the Pi extension, so a full core image can contain it if the core file itself is stored. COREDUMP_ENVIRON no longer contains it.McpSessionRegistry keeps credentials in memory only. The directories are 0700.ProviderSessionManager.ts:1978).accepted. The maintainer triage confirmed the coredump exposure and asked for a non-env channel.477282263a: the fix, a knip follow-up that un-exports LEGACY_RAW_MCP_CREDENTIAL_ENV, and a hardening commit for the credential-file helper. 20 files, +930 / -107, most of it tests.Part of #12031.
Focused tests, run from the repo root:
vp test run --maxWorkers=2 apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.test.ts apps/server/src/provider/acp/AcpJsonRpcConnection.test.ts apps/server/src/mcp/AcpMcpStdioBridge.test.ts packages/provider-acp/src/server/clientTerminals.test.ts packages/provider-pi/src/server/adapter.test.ts packages/provider-pi/src/server/mcpInjection.test.ts packages/provider-pi/src/server/mcpExtensionSource.test.ts packages/provider-core/src/server/mcpSession.test.ts
Test Files 8 passed (8)
Tests 312 passed (312)
New and changed tests:
keeps an ACP thread's MCP credential file at one path through rotation and clear: after a rotation and a turn on the same native session there is still one runtime, the same path holds the new header, and a terminal started afterwards reads it through its remembered environment. The next read after a clear removes the file, a reissue restores it at the same path, and closing the session removes it.opens an ACP session without T3's MCP server when its credential file cannot be written: no t3-code server and no file variable, and the agent does not see a stale raw variable.drops a raw MCP credential the server inherited from an older build: raw values for all three legacy names, seeded in the parent process.env, do not reach the spawned agent. The mock agent's probe checks all three.clientTerminals.environment; terminals of a session without a credential and of a session with one both print it empty.reads the credential from the file the environment names for the bridge and acp-mcp-call.hands Pi the MCP credential as a session-owned file, not in its environment: the file is 0600 and gone after close. The Pi launch test in mcpInjection.test.ts seeds all three legacy names plus a stale URL and file variable and asserts each is gone.mcpSession.test.ts, 10 new tests, four of them in the next bullets. For makeMcpCredentialFiles on the real filesystem: an unchanged header is a no-op (same inode); rotation keeps the path and mode 0600 and replaces the inode; remove then write puts the file back at the same path; an injected rename failure leaves no .tmp, remove clears a key with no recorded header, and a failed rotation keeps the old header; closing the scope removes every key's directory. For withoutRawMcpCredentials: all three names masked and the rest kept; an unset environment starts from process.env.writes the file again after a removal that stopped part way: remove deletes the file, then an injected failure stops it at the .tmp; a write of the same header puts the file back at the same path.writes the file again after a removal that was interrupted part way: remove deletes the file and is interrupted while it deletes the .tmp; a write of the same header puts the file back at the same path.replaces a leftover temporary file instead of writing into it: a .tmp left with mode 0644 does not survive the next write, and the file ends up 0600 with the new header.does not write into a temporary file created after the leftover is deleted: a readable .tmp that appears between the delete and the exclusive create makes that create fail with AlreadyExists. The file keeps the old header, the planted file never gets the new one, and no .tmp is left.Related suites, every test that builds AcpSessionRuntime since its spawn environment changed. Both runs are on the fix commit 336a55f9e7, before the two follow-ups:
vp test run apps/server/src/orchestration-v2/Adapters/AcpRegistryAdapterV2.test.ts apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.test.ts apps/server/src/orchestration-v2/Adapters/GrokAdapterV2.test.ts packages/provider-acp/src/server packages/provider-acp-registry/src/server apps/server/src/provider/acp apps/server/src/provider/AcpRegistryProbe.test.ts apps/server/src/provider/AntigravityAuth.test.ts apps/server/src/provider/AntigravityProvider.test.ts apps/server/src/textGeneration/AntigravityTextGeneration.test.ts
Test Files 1 failed | 23 passed (24)
Tests 1 failed | 429 passed (430)
vp test run apps/server/src/orchestration-v2/testkit/OrchestratorReplayFixtures.integration.test.ts packages/provider-pi/src/server packages/provider-grok/src/server packages/provider-core/src/server
Test Files 35 passed | 1 skipped (36)
Tests 579 passed | 4 skipped (583)
The one failure is AcpSessionRuntime.processTree.test.ts "contains a packaged-runtime command without requiring cgroup delegation" (expected 127 to be 125), and this PR does not touch that test or the wrapper it exercises. It fails the same way where /bin/sh is bash, also on the earlier main a8bdfdb5 before the rebase, and passes where /bin/sh is dash, as in upstream CI on this PR. #17949 fixes it separately, carrying forward #15344.
Red/green: with the new strip tests on the source from before the strip existed (file channel only), all four fail: the parent-seed test (the agent sees the raw variable), the rotation test (the agent sees the stale raw value, the Grok case), the write-failure test (same), and the fork test (the terminal of a session without a credential prints Bearer stale-dummy-credential|). I did not run the new tests against 477282263a or a8bdfdb5, where the *_AUTHORIZATION_FILE assertions would fail too.
Red/green for the hardening commit: with the partial-removal and leftover-.tmp tests on the helper from before it, both fail (the file is missing after the partial removal; the file ends up with the leftover .tmp's mode 0644). The interrupted-removal and planted-.tmp tests each fail when one part of the change is undone. With remove forgetting the header after the deletes again, the interrupted-removal test fails because the file is missing, and so does the partial-removal one. With flag: "wx" dropped and the pre-delete kept, the planted-.tmp test fails because the rotation succeeds. With the change, mcpSession.test.ts passes 12 of 12.
Mutation checks, one per new behavior, each source file restored and checksum-verified afterwards. The first five ran on an earlier revision with the same call sites, the last five on the fix commit's code, and the two Pi ones again after the rebase. All ten predate the hardening commit.
| Mutation | Result |
|---|---|
| Agent spawn without the strip helper | 3 fail: the parent-seed, rotation and write-failure tests (the agent sees the raw variable) |
| Client terminals without the strip helper | fork test fails: expected 'Bearer stale-dummy-credential|' to equal '|' |
| Rotation deletes the old file and writes a new path | rotation test fails: NotFound: FileSystem.readFile on the path the agent and terminals were given |
remove leaves the file on clear |
rotation test fails: expected true to be false on exists(file) after clear |
| ACP write failure raised instead of logged | write-failure test fails: ProviderAdapterOpenSessionError ... PermissionDenied: FileSystem.makeTempFileScoped |
A failed write keeps its .tmp |
"leaves no temporary file behind when a write fails" fails: expected true to be false on exists(<path>.tmp) |
remove returns early when no header is recorded |
same test fails: the empty file still exists after remove |
Pi deletes only T3_MCP_BEARER_TOKEN |
Pi launch test fails: expected 'Bearer stale-token' to equal undefined |
The shared list loses T3_CODE_MCP_AUTHORIZATION |
2 fail: the strip helper's strict-shape test and the Pi launch test |
write drops the unchanged-header check |
"keeps a key's path through a rotation and skips an unchanged header" fails on the inode |
The rename step and the semaphore have no mutation check, because no test races a reader or a second writer against a write.
tsc --noEmit through each package's typecheck script in provider-core, provider-acp, provider-pi and apps/server: exit 0, 0 errors.vp lint --report-unused-disable-directives on the changed .ts files: 0 errors. 4 warnings, all on lines this PR does not change.vp fmt --check on the changed files: All matched files use the correct format.provider-core, provider-acp and apps/server typechecks exit 0 with 0 errors (it does not touch provider-pi), vp lint and vp fmt --check on its six files are clean, and vp run knip:check reports nothing.These checks ran before the rebase, on the earlier main a8bdfdb5 and on this change on that base (36da67d1). The rebase onto 477282263a was conflict-only: it left the ACP and core code byte-identical and changed Pi's launch code only by upstream's new extension-path lines. The checks also predate the two follow-up commits, and I did not repeat them. The knip commit drops one export. The hardening commit changes how mcpSession.ts writes the .tmp and when remove forgets the header, plus the ACP warning text, the mock agent's probe, a docs sentence, comments and tests. None of that decides what goes into a child's environment, so the environment and crash-dump results stand. The rotation, file mode and cleanup in the third image went through the earlier write code; the unit tests above cover the new one.
Main and this change each ran in a throwaway clone, under env -i with a private HOME and TMPDIR. A temporary test file that is not part of this PR drove the real code: makeAcpRegistryAdapterV2 spawning the repo's acp-mock-agent.ts, makeAcpAdapterV2 with mcpServers pointing at the clone's real t3 acp-mcp-bridge, and buildPiRpcLaunch. Each child's /proc/<pid>/environ was read and filtered to T3 MCP variables. The credential was a dummy, Bearer dummy-e1-00112233445566778899aabbccddeeff, and the MCP endpoint was a local dummy HTTP server that logs each request's Authorization header. Both clones were clean afterwards.
Child environments. ACP agent process (the T3_ACP_MCP_NODE and T3_ACP_MCP_ENTRYPOINT lines omitted):
# before (main)
T3_ACP_MCP_AUTHORIZATION=Bearer dummy-e1-00112233445566778899aabbccddeeff
T3_ACP_MCP_ENDPOINT=http://127.0.0.1:43123/mcp
# after (this branch)
T3_ACP_MCP_AUTHORIZATION_FILE=$TMPDIR/t3-mcp-XXXXXX/<random>
T3_ACP_MCP_ENDPOINT=http://127.0.0.1:43123/mcp
The bridge, the client terminal and the Pi child show the same change (T3_MCP_BEARER_TOKEN becomes T3_MCP_AUTHORIZATION_FILE for Pi). Two more runs put stale raw copies in the environment of the process standing in for the T3 server and opened a session with no credential:
# before, server env has T3_ACP_MCP_AUTHORIZATION: ACP agent and its client terminal
T3_ACP_MCP_AUTHORIZATION=Bearer dummy-stale-inherited
# before, server env has T3_MCP_BEARER_TOKEN and T3_CODE_MCP_AUTHORIZATION: ACP agent and its client terminal
T3_CODE_MCP_AUTHORIZATION=Bearer dummy-stale-inherited
T3_MCP_BEARER_TOKEN=dummy-stale-inherited
# after, both runs: ACP agent and its client terminal
<no T3 MCP variables>
Crash dumps. For each captured environment, a dummy /usr/bin/sleep ran as a transient user unit with exactly those T3 MCP variables, was crashed with SIGSEGV, and COREDUMP_ENVIRON was filtered to T3 MCP lines. The dummy core files were deleted afterwards.
$ systemd-run --user --collect --unit=$UNIT -p LimitCORE=infinity -E T3_...=... /usr/bin/sleep 300
$ systemctl --user kill -s SEGV $UNIT
$ journalctl --user COREDUMP_USER_UNIT=$UNIT.service -o json --all --output-fields=COREDUMP_ENVIRON
# before, t3 acp-mcp-bridge environment
T3_ACP_MCP_AUTHORIZATION=Bearer dummy-e1-00112233445566778899aabbccddeeff
T3_ACP_MCP_ENDPOINT=http://127.0.0.1:33005/mcp
# after
T3_ACP_MCP_AUTHORIZATION_FILE=$TMPDIR/t3-mcp-XXXXXX/<random>
T3_ACP_MCP_ENDPOINT=http://127.0.0.1:46271/mcp
All four channels (agent, bridge, terminal, Pi) held the dummy bearer before and only the path after.
The credential still works. On this branch, the bridge started from the exact mcpServers spec, acp-mcp-call from a client terminal, and the Pi extension (loaded with Pi's environment, real fs and real fetch) each sent the issued header. After a rotation the file at the same path held the new header and acp-mcp-call sent it:
native session: mock-session-1; agent processes started: 1
file before rotation: Bearer dummy-... (matches dummy: true)
file after rotation: Bearer dummy-... (matches rotated dummy: true)
new terminal's T3_ACP_MCP_AUTHORIZATION_FILE is the same path: true
acp-mcp-call stdout: {"content":[{"type":"text","text":"e1 probe ok"}]}
server received tools/call: Authorization: Bearer dummy-... (matches rotated dummy: true)
The file was 0600 in a 0700 directory, and both were gone once the owning scope closed. No t3-mcp-* directory was left in TMPDIR. The bridge given only the old raw variable exits with code 2.
A live T3 thread. A dev server from this branch, loopback only, with an isolated T3 home and an ACP registry instance running codex-acp. One prompt asked the agent to call orchestrator_capabilities. The call went through t3 acp-mcp-bridge, completed, and the agent reported 10 providers. While the agent was alive I listed only the variable names in its environment and the bridge's. The codex-acp process had T3_ACP_MCP_AUTHORIZATION_FILE, T3_ACP_MCP_ENDPOINT, T3_ACP_MCP_ENTRYPOINT and T3_ACP_MCP_NODE. The bridge had T3_ACP_MCP_AUTHORIZATION_FILE and T3_ACP_MCP_ENDPOINT. Neither had T3_ACP_MCP_AUTHORIZATION.
Not checked:
os.tmpdir() is per user on both and rename replaces an existing file on both, but I ran neither. On Windows the mode is ignored and the file gets the ACL of the user's temp directory; I did not check that ACL.pi binary. The Pi environment came from buildPiRpcLaunch without starting Pi, and the extension ran in a vm context, as the repo's testkit does.codex-acp through the registry driver.sleep carrying each captured environment.Model and harness: Claude Opus 5.5 in Claude Code, run from T3 Code.
🤖 Generated with Claude Code
Sorry, something went wrong.
There was an error while loading. Please reload this page.
ACP agents, the `t3 acp-mcp-bridge` stdio server they spawn, ACP client terminals and Pi received the thread's MCP bearer in an environment variable. Everything those processes spawn inherits it, and on Linux systemd-coredump writes the environment of a crashing process to the journal as COREDUMP_ENVIRON. ACP and Pi now write the Authorization header to an owner-only file in a private temporary directory and pass only its path (T3_ACP_MCP_AUTHORIZATION_FILE, T3_MCP_AUTHORIZATION_FILE). The bridge, `t3 acp-mcp-call` and the Pi extension read the file. ACP keeps one path per thread for the life of the provider session. A rotated header is written beside the file and renamed over it. Once the credential is cleared, the next read deletes the file, and a reissued credential comes back at the same path. A failed write leaves no temporary file. Pi writes its file once when the session opens. Closing the session removes the files. If the file cannot be written, ACP runs the session without T3's MCP server and Pi fails to open the session, as it does when it cannot write its extension. The raw-credential variables older builds exported (T3_ACP_MCP_AUTHORIZATION, T3_MCP_BEARER_TOKEN, T3_CODE_MCP_AUTHORIZATION) are dropped where every ACP flavor spawns its agent, where ACP client terminals start, and from Pi's launch environment, whether or not the session has a credential. The MCP server doc now describes how Codex receives its header (JSON-RPC thread config, not an environment variable). Refs pingdotgg#12031 Co-Authored-By: Claude Opus 5.5 <[email protected]>
ApprovabilityVerdict: Not approved Macroscope's review found this PR not approvable — This PR changes the default authentication-credential transport for ACP and Pi processes, adding session-owned files, rotation and cleanup logic, and broad child-environment sanitization. Because it affects security-sensitive production behavior across multiple provider paths, human review is required. You can add or adjust custom eligibility rules. Learn more. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
knip flagged the export; it is only used inside mcpSession.ts. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
remove() now forgets the recorded header before it deletes anything, so a removal that fails or is interrupted part way cannot leave a header that a later write of the same value trusts while the file is gone. write() deletes any leftover .tmp and creates the new one exclusively with mode 0600, so it never writes into a .tmp that already exists, whether it was left over or appeared after the delete. Also: the ACP log says "update" since it covers clears too; the mock agent's probe checks all three legacy names, and the test that seeds them in the parent environment now seeds all three; the docs and the helper comments say what protects the file on POSIX and on Windows; one test is renamed to say what it checks. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Note Written by Thanks for tracing the MCP credential exposure. This changes 1,037 lines across 20 files, which exceeds what we can take over from an unvouched contributor under our current limited review capacity. Right now we are only taking focused bug fixes from outside contributors. Please keep the ACP/Pi exposure documented in #12031 and agree on a smaller provider-specific fix with a maintainer before requesting reconsideration. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.