Skip to content

Keep COMPUTER_TOKEN out of reach of the computer's own children - #892

Closed
prysthedev wants to merge 1 commit into
CopilotKit:mainfrom
prysthedev:fix/computer-token-out-of-reach
Closed

prysthedev wants to merge 1 commit into
CopilotKit:mainfrom
prysthedev:fix/computer-token-out-of-reach

Conversation

@prysthedev

Copy link
Copy Markdown

A Bot's shell commands get a scrubbed environment (shell.ts), but they run as the same user as the computer process, and so do Chromium and Xvfb, which Playwright launches with the full process environment. A command could read COMPUTER_TOKEN back from another process's /proc/<pid>/environ. With it, a command can call the computer API directly, outside the server's gateway, and on a computer several people share, for any seat.

Changes:

  • agent-computer/src/secret-env.ts: takeSecretFromEnv reads the token and deletes it from process.env, so no child started afterwards inherits it.
  • hideProcessFromChildren sets PR_SET_DUMPABLE=0 through bun:ffi on Linux, so a same-user process without CAP_SYS_PTRACE cannot read the computer's environment or memory. COMPUTER_DUMPABLE=on opts out; a failure is logged, not fatal.
  • index.ts uses both before anything is spawned. docs/architecture.md says what this does and does not cover.

Not covered: root with CAP_SYS_PTRACE, or the container's own environment files (the one-container image's apt sudo rule reaches root). A per-computer token in supervisor mode would be a sensible follow-up.

Tests: agent-computer/tests/secret-env.test.ts.

A Bot's shell commands are given a scrubbed environment, but they run as
the same user as the computer process, and so do Chromium and Xvfb,
which Playwright launches with the full process environment. Any of
them could read the token back from /proc/<pid>/environ, either the
computer's own or the browser's. With the token, a command can call the
computer API directly, which bypasses the server's gateway, and on a
computer several people share it can act on any seat.

The computer now removes COMPUTER_TOKEN from process.env as it reads it,
so no child inherits it, and marks itself non-dumpable on Linux
(PR_SET_DUMPABLE), so a same-user process without CAP_SYS_PTRACE cannot
read its environment or memory. COMPUTER_DUMPABLE=on opts out for
debugging; a failure to set it is logged rather than fatal.

Not covered: a command that can reach root with CAP_SYS_PTRACE, or the
container's environment files (the one-container image's apt sudo rule
reaches root). Per-computer tokens in supervisor mode would be the next
layer of defence.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-29T23:38:08.509109Z
We couldn’t complete this review. Comment @codex review to try again.
70cf80f PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@prysthedev prysthedev closed this Oct 30, 2026
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.

2 participants