code_mode_host app-server runs with umask 0077, silently creating 0600/0700 project files that break multi-user deployments

Open
#37,296 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
linux, rust

Research direction

Start by locating the code_mode_host app-server startup path and inspect how its process umask is established on Linux. Reproduce the issue in a multi-user deployment, then verify that project files and directories created by the app-server have usable permissions rather than silently becoming 0600/0700.

Written by the indexing model from the issue text.

Description

app-server bug
What version of Codex CLI is running?

codex-cli 0.146.1

What subscription do you have?

Pro

Which model were you using?

Gpt-5.6-sol

What platform is your computer?

Linux

What terminal emulator and version are you using (if applicable)?

Ghostty

Codex doctor report
{
  "schemaVersion": 1,
  "generatedAt": "1786029303s since unix epoch",
  "overallStatus": "ok",
  "codexVersion": "0.146.1",
  "checks": {
    "app_server.status": {
      "id": "app_server.status",
      "category": "app-server",
      "status": "ok",
      "summary": "background server is running",
      "details": {
        "app-server version": "0.146.1",
        "control socket": "/root/.codex/app-server-control/app-server-control.sock",
        "daemon state dir": "/root/.codex/app-server-daemon",
        "mode": "ephemeral",
        "pid file": "/root/.codex/app-server-daemon/app-server.pid (missing)",
        "settings": "/root/.codex/app-server-daemon/settings.json (missing)",
        "status": "running",
        "update-loop pid file": "/root/.codex/app-server-daemon/app-server-updater.pid (missing)"
      },
      "remediation": null,
      "durationMs": 170
    },
    "auth.credentials": {
      "id": "auth.credentials",
      "category": "auth",
      "status": "ok",
      "summary": "auth is configured",
      "details": {
        "auth file": "/root/.codex/auth.json",
        "auth storage mode": "File",
        "stored API key": "false",
        "stored ChatGPT tokens": "true",
        "stored agent identity": "false",
        "stored auth mode": "chatgpt"
      },
      "remediation": null,
      "durationMs": 0
    },
    "config.load": {
      "id": "config.load",
      "category": "config",
      "status": "ok",
      "summary": "config loaded",
      "details": {
        "CODEX_HOME": "/root/.codex",
        "config.toml": "/root/.codex/config.toml",
        "config.toml parse": "ok",
        "cwd": "/root",
        "enabled feature flags": "shell_tool, unified_exec, shell_snapshot, terminal_resize_reflow, sqlite, hooks, enable_request_compression, multi_agent, apps, tool_search_always_defer_mcp_tools, tool_suggest, plugins, in_app_browser, in_app_updates, browser_use, browser_use_full_cdp_access, browser_use_external, computer_use, remote_plugin, plugin_sharing, image_generation, resize_all_images, item_ids, skill_mcp_dependency_install, skill_search, mentions_v2, steer, guardian_approval, goals, collaboration_modes, tool_call_mcp_elicitation, auth_elicitation, personality, fast_mode, tui_app_server, remote_compaction_v2, workspace_dependencies",
        "feature flag overrides": "code_mode_host=false",
        "feature flags enabled": "37",
        "log dir": "/root/.codex/log",
        "mcp servers": "3",
        "model": "gpt-5.6-sol",
        "model provider": "openai",
        "sqlite home": "/root/.codex"
      },
      "remediation": null,
      "durationMs": 0
    },
    "git.environment": {
      "id": "git.environment",
      "category": "git",
      "status": "ok",
      "summary": "git version 2.34.1",
      "details": {
        ".git entry": "directory",
        "PATH git #1": "/usr/bin/git",
        "PATH git #2": "/bin/git",
        "PATH git entries": "2",
        "git build options": "git version 2.34.1; cpu: x86_64; no commit associated with this build; sizeof-long: 8; sizeof-size_t: 8; shell-path: /bin/sh",
        "git exec path": "/usr/lib/git-core",
        "git version": "git version 2.34.1",
        "repo detected": "true",
        "repo root": "/root",
        "selected git": "/usr/bin/git"
      },
      "remediation": null,
      "durationMs": 86
    },
    "installation": {
      "id": "installation",
      "category": "install",
      "status": "ok",
      "summary": "installation looks consistent",
      "details": {
        "PATH codex #1": "/root/.local/bin/codex",
        "current executable": "/root/.local/lib/node_modules/@openai/codex/node_modules/@openai/codex-linux-x64/vendor/x86_64-unknown-linux-musl/bin/codex",
        "install context": "npm (package /root/.local/lib/node_modules/@openai/codex/node_modules/@openai/codex-linux-x64/vendor/x86_64-unknown-linux-musl, bin /root/.local/lib/node_modules/@openai/codex/node_modules/@openai/codex-linux-x64/vendor/x86_64-unknown-linux-musl/bin, resources /root/.local/lib/node_modules/@openai/codex/node_modules/@openai/codex-linux-x64/vendor/x86_64-unknown-linux-musl/codex-resources, path /root/.local/lib/node_modules/@openai/codex/node_modules/@openai/codex-linux-x64/vendor/x86_64-unknown-linux-musl/codex-path)",
        "managed by bun": "false",
        "managed by npm": "true",
        "managed by pnpm": "false",
        "managed package root": "/root/.local/lib/node_modules/@openai/codex",
        "npm update target": "/root/.local/lib/node_modules/@openai/codex"
      },
      "remediation": null,
      "durationMs": 76
    },
    "mcp.config": {
      "id": "mcp.config",
      "category": "mcp",
      "status": "ok",
      "summary": "MCP configuration is locally consistent",
      "details": {
        "configured servers": "3",
        "disabled servers": "0",
        "streamable_http servers": "3"
      },
      "remediation": null,
      "durationMs": 1007
    },
    "network.env": {
      "id": "network.env",
      "category": "network",
      "status": "ok",
      "summary": "network-related environment looks readable",
      "details": {
        "proxy env vars": "none"
      },
      "remediation": null,
      "durationMs": 0
    },
    "network.provider_reachability": {
      "id": "network.provider_reachability",
      "category": "reachability",
      "status": "ok",
      "summary": "active provider endpoints are reachable over HTTP",
      "details": {
        "ChatGPT base URL": "https://chatgpt.com/backend-api/ reachable (HTTP 403)",
        "reachability mode": "ChatGPT auth"
      },
      "remediation": null,
      "durationMs": 118
    },
    "network.websocket_reachability": {
      "id": "network.websocket_reachability",
      "category": "websocket",
      "status": "ok",
      "summary": "Responses WebSocket handshake succeeded",
      "details": {
        "DNS": "2 IPv4, 2 IPv6, first IPv6",
        "auth mode": "chatgpt",
        "connect timeout": "15000 ms",
        "endpoint": "wss://chatgpt.com/backend-api/<redacted>",
        "handshake result": "HTTP 101 Switching Protocols",
        "model provider": "openai",
        "models etag present": "true",
        "provider name": "OpenAI",
        "proxy env vars": "none",
        "reasoning header": "false",
        "server model present": "false",
        "supports websockets": "true",
        "wire API": "responses"
      },
      "remediation": null,
      "durationMs": 616
    },
    "runtime.provenance": {
      "id": "runtime.provenance",
      "category": "runtime",
      "status": "ok",
      "summary": "running npm on linux-x86_64",
      "details": {
        "commit": "unknown",
        "current executable": "/root/.local/lib/node_modules/@openai/codex/node_modules/@openai/codex-linux-x64/vendor/x86_64-unknown-linux-musl/bin/codex",
        "install method": "npm (package /root/.local/lib/node_modules/@openai/codex/node_modules/@openai/codex-linux-x64/vendor/x86_64-unknown-linux-musl, bin /root/.local/lib/node_modules/@openai/codex/node_modules/@openai/codex-linux-x64/vendor/x86_64-unknown-linux-musl/bin, resources /root/.local/lib/node_modules/@openai/codex/node_modules/@openai/codex-linux-x64/vendor/x86_64-unknown-linux-musl/codex-resources, path /root/.local/lib/node_modules/@openai/codex/node_modules/@openai/codex-linux-x64/vendor/x86_64-unknown-linux-musl/codex-path)",
        "platform": "linux-x86_64",
        "version": "0.146.1"
      },
      "remediation": null,
      "durationMs": 0
    },
    "runtime.search": {
      "id": "runtime.search",
      "category": "search",
      "status": "ok",
      "summary": "search is OK (bundled)",
      "details": {
        "search command": "/root/.local/lib/node_modules/@openai/codex/node_modules/@openai/codex-linux-x64/vendor/x86_64-unknown-linux-musl/codex-path/rg",
        "search command readiness": "file exists",
        "search provider": "bundled"
      },
      "remediation": null,
      "durationMs": 0
    },
    "sandbox.helpers": {
      "id": "sandbox.helpers",
      "category": "sandbox",
      "status": "ok",
      "summary": "sandbox configuration is readable",
      "details": {
        "approval policy": "OnRequest",
        "codex-linux-sandbox helper": "/root/.codex/tmp/arg0/codex-arg0ElRtnQ/codex-linux-sandbox",
        "execve wrapper helper": "/root/.codex/tmp/arg0/codex-arg0ElRtnQ/codex-execve-wrapper",
        "filesystem sandbox": "restricted",
        "network sandbox": "restricted"
      },
      "remediation": null,
      "durationMs": 0
    },
    "state.paths": {
      "id": "state.paths",
      "category": "state",
      "status": "ok",
      "summary": "state paths and databases are inspectable",
      "details": {
        "CODEX_HOME": "/root/.codex (dir)",
        "active rollout files": "614 files, 5738055544 total bytes, 9345367 average bytes",
        "archived rollout files": "13 files, 6031721 total bytes, 463978 average bytes",
        "goals DB": "/root/.codex/goals_1.sqlite (file)",
        "goals DB integrity": "ok",
        "log DB": "/root/.codex/logs_2.sqlite (file)",
        "log DB integrity": "ok",
        "log dir": "/root/.codex/log (dir)",
        "memories DB": "/root/.codex/memories_1.sqlite (file)",
        "memories DB integrity": "ok",
        "sqlite home": "/root/.codex (dir)",
        "state DB": "/root/.codex/state_5.sqlite (file)",
        "state DB integrity": "ok",
        "thread history DB": "/root/.codex/thread_history_1.sqlite (missing)",
        "thread history DB integrity": "skipped (missing)"
      },
      "remediation": null,
      "durationMs": 3608
    },
    "state.rollout_db_parity": {
      "id": "state.rollout_db_parity",
      "category": "threads",
      "status": "ok",
      "summary": "rollout files and state DB thread inventory agree",
      "details": {
        "default model provider": "openai",
        "rollout DB active files": "614",
        "rollout DB active rows": "614",
        "rollout DB archive mismatches": "0",
        "rollout DB archived files": "13",
        "rollout DB archived rows": "13",
        "rollout DB duplicate DB paths": "0",
        "rollout DB duplicate rollout thread ids": "0",
        "rollout DB malformed file names": "0",
        "rollout DB missing active rows": "0",
        "rollout DB missing archived rows": "0",
        "rollout DB model providers": "openai=627",
        "rollout DB rows": "627",
        "rollout DB scan cap reached": "false",
        "rollout DB scan errors": "0",
        "rollout DB sources": "subagent:other=384, vscode=112, exec=105, cli=18, subagent:thread_spawn=8",
        "rollout DB stale rows": "0"
      },
      "remediation": null,
      "durationMs": 463
    },
    "system.environment": {
      "id": "system.environment",
      "category": "system",
      "status": "ok",
      "summary": "OS language en-US",
      "details": {
        "EDITOR": "not set",
        "LANG": "en_US.UTF-8",
        "VISUAL": "not set",
        "os": "Ubuntu 22.4.0 (jammy) [64-bit]",
        "os language": "en-US",
        "os type": "Ubuntu",
        "os version": "22.4.0"
      },
      "remediation": null,
      "durationMs": 59
    },
    "terminal.env": {
      "id": "terminal.env",
      "category": "terminal",
      "status": "ok",
      "summary": "terminal metadata was detected",
      "details": {
        "SSH_CLIENT": "present",
        "SSH_CONNECTION": "present",
        "SSH_TTY": "present",
        "TERM": "xterm-ghostty",
        "color output": "enabled",
        "effective locale": "en_US.UTF-8",
        "stderr is terminal": "true",
        "stdin is terminal": "true",
        "stdout is terminal": "true",
        "terminal": "unknown",
        "terminal size": "160x57"
      },
      "remediation": null,
      "durationMs": 0
    },
    "terminal.title": {
      "id": "terminal.title",
      "category": "title",
      "status": "ok",
      "summary": "terminal title default",
      "details": {
        "terminal title activity": "true",
        "terminal title items": "activity, project-name",
        "terminal title project source": "git repo root",
        "terminal title project value": "root",
        "terminal title source": "default"
      },
      "remediation": null,
      "durationMs": 0
    },
    "updates.status": {
      "id": "updates.status",
      "category": "updates",
      "status": "ok",
      "summary": "update configuration is locally consistent",
      "details": {
        "cached latest version": "0.146.1",
        "check for update on startup": "true",
        "last checked at": "2026-08-05T23:31:45.463282819Z",
        "latest version": "0.146.1",
        "latest version status": "current version is not older",
        "npm update target": "/root/.local/lib/node_modules/@openai/codex",
        "update action": "npm install -g @openai/codex",
        "version cache": "/root/.codex/version.json"
      },
      "remediation": null,
      "durationMs": 172
    }
  }
}
What issue are you seeing?

The app-server that the Codex client launches with -c features.code_mode_host=true
runs with umask 0077, and every process it spawns inherits it — the code-mode
child, the sandbox launcher, bwrap, and every command a conversation executes. All
files created through code-mode conversations arrive 0600 and directories
0700 instead of the customary 0644/0755.

Verified via /proc/<pid>/status on the same machine, same version:

process umask
codex -c features.code_mode_host=true app-server --listen 0077
its code-mode child → sandbox launcher → bwrap → executed command 0077
plain codex resume CLI session 0022
plain codex app-server proxy 0022

The vendored Bubblewrap deliberately saves and restores the parent's umask
(old_umask = umask (0); ... umask (old_umask); in vendor/bubblewrap/bubblewrap.c),
so the sandbox faithfully propagates the app-server's 0077 into user commands.

If the 0077 is intentional hardening for Codex-internal files, it leaks beyond
them: ordinary project files and production build artifacts (e.g. a Vite build)
come out owner-only with no warning. Git doesn't track 0600 vs 0644, and
single-user setups never notice. In our environment (Codex as root; nginx and
systemd services as non-root users; mode-preserving rsync -a deploys) this
caused public 403s on a deployed frontend and a PermissionError on a service
importing a newly created Python module. It took days to trace, because plain-CLI
sessions on the same box produced normal 0644 files the whole time, making the
failures look intermittent.

Also: codex features disable code_mode_host writes the config correctly
(codex features list shows false), but the client launcher's
-c features.code_mode_host=true command-line flag overrides it, so there is no
user-accessible way to opt out.

What steps can reproduce the bug?
  1. Connect with a client that launches the code-mode app-server (process cmdline:
    codex -c features.code_mode_host=true app-server --listen).

  2. In a conversation, run:

    umask; mkdir d; touch d/f; ls -la d

  3. Observe:

    0077
    drwx------ d
    -rw------- d/f

  4. Compare with a plain codex CLI session on the same machine:

    0022
    drwxr-xr-x
    -rw-r--r--

  5. Confirm the host-side chain: grep Umask /proc/<app-server-pid>/status and
    each descendant — all 0077.

What is the expected behavior?

Files created by a user's commands in code-mode conversations should have the
same modes as in any other Codex session: 0644 files, 0755 directories (umask
0022). Specifically, one of:

  • scope any 0077 hardening to Codex-internal files and run project-file
    operations at 0022, or
  • make the umask configurable and/or honor codex features disable code_mode_host instead of overriding it with the launcher flag, or
  • at minimum, document prominently that code-mode output is owner-only and must
    be permission-normalized before deployment.
Additional information

No response

Dominant language
Rust
Stars
125k
Forks
19.5k
Avg merge
1m
Merged PRs (30d)
1k

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from openai/codex

All issues in openai/codex

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.