Finalize `shell_environment_policy` configuration option

Resolved 💬 1 comment Opened Jun 6, 2025 by bolinfest Closed Nov 5, 2025

Admittedly, the shell_environment_policy configuration option is a bit complicated:

https://github.com/openai/codex/blob/main/codex-rs/config.md#shell_environment_policy

Similar to https://github.com/openai/codex/issues/1248, it aims to be configurable but the current API comes at the cost of being simple.

For context, the high-level motivation behind this feature was:

  • Don't let the agent spawn processes with an environment that contains sensitive information that might let it exfiltrate or abuse that information. (You can see that MCP seems to share this design principle, as you must specify the environment used to spawn an MCP server in most tools that take mcpServers in a JSON config file.)
  • Provide an environment to subprocesses intentionally (by configuring it via shell_environment_policy) as opposed to accidentally (by inheriting the env of wherever you happened to launch codex).

While this motivation is well-intentioned, it is not clear how well it achieves the goals. For example, even if we scrub sensitive values from the environment, if those values are readable via the user's ~/.bashrc or ~/.zprofile or whatever and the agent can read all files on disk, then we haven't really protected against anything.

It would be helpful to get feedback from the community before finalizing this config option.

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗