Skip to content

codex TUI on Linux not honouring shell_environment_policy #22124

@aussielunix

Description

@aussielunix

What version of Codex CLI is running?

codex-cli 0.130.0 installed via homebrew

What subscription do you have?

pro

Which model were you using?

gpt-5.5

What platform is your computer?

Linux 6.19.14-300.fc44.x86_64 x86_64 unknown

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

terminator 2.1.5 running bash and no tmux/screen

What issue are you seeing?

The codex TUI on Linux appears to not be honoring a strict shell_environment_policy

TUI tool execution should see only PATH, HOME, and MY_FLAG; actual behavior: it sees the full parent user environment.

What steps can reproduce the bug?

I have the following in ~/.codex/config.toml

approval_policy = "on-request"
sandbox_mode = "read-only"
web_search = "disabled"
allow_login_shell = false

[shell_environment_policy]
inherit = "none"
set = { PATH = "/usr/bin", MY_FLAG = "1" }
ignore_default_excludes = false
exclude = ["AWS_*", "AZURE_*", "HOMEBREW*"]
include_only = ["PATH", "HOME", "MY_FLAG"]

When I run the following all of my user's environment variables are visible which is not what I expected.

lunix@astro]  -> codex
codex prompt> env | sort
• Ran env | sort
  └ CODEX_CI=1
    CODEX_SANDBOX_NETWORK_DISABLED=1
    … +30 lines (ctrl + t to view transcript)
    XDG_DATA_DIRS=/var/home/lunix/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/share
    _=/usr/bin/env

─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

• CODEX_CI=1
  CODEX_SANDBOX_NETWORK_DISABLED=1
  CODEX_THREAD_ID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx
  COLORTERM=
  EDITOR=vim
  GH_PAGER=cat
  GIT_PAGER=cat
  HISTSIZE=5000
  HOME=/var/home/lunix
  HOMEBREW_BUNDLE_FILE=/var/home/lunix/Brewfile
  HOMEBREW_NO_ANALYTICS=1
  HOMEBREW_NO_AUTO_UPDATE=1
  LANG=C.UTF-8
  LC_CTYPE=C.UTF-8
  LESS=-R
  LESSOPEN=||/usr/bin/lesspipe.sh %s
  NO_COLOR=1
  PAGER=cat
  PATH=xxxxxxx<trimmed>xxxxx
  PWD=/var/home/lunix/Code/xxxxxxxxxxxxxxxxxxx
  SCRT_GIT_PATH=test.scrt
  SCRT_GIT_URL=git@xxxx.xxxx:xxxxxxx/xxxxx.git
  SCRT_STORAGE=git
  SHELL=/bin/bash
  SHLVL=1
  SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass
  SYSTEMD_PAGER=
  TERM=dumb
  USER=lunix
  XDG_DATA_DIRS=/var/home/lunix/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/share
  _=/usr/bin/env

What is the expected behavior?

When I run the following I get the expected results.
I would expect the same results when running the TUI.

lunix@astro]  -> codex sandbox linux -- env
CODEX_SANDBOX_NETWORK_DISABLED=1
MY_FLAG=1
PATH=/usr/bin
PWD=/var/home/lunix/Code/xxxxxxxxxxxxxxxxxxx

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingsandboxIssues related to permissions or sandboxing

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions