Replies: 5 comments 3 replies
-
|
At least on macOS we could leverage the sanbox adding some filter up: this will totally hide files from the sandbox reaching the best level of security. https://github.com/openai/codex/blob/main/codex-rs/core/src/seatbelt.rs I don't know how claude code is operating on this but it seems that can give this sort of security: https://www.devproblems.com/securing-claude-code-protecting-your-sensitive-files-like-env/ IMHO having a protection at sandbox level gives the best guarantee. |
Beta Was this translation helpful? Give feedback.
-
🧱 macOS —
|
Beta Was this translation helpful? Give feedback.
-
|
Great thread, my guy! |
Beta Was this translation helpful? Give feedback.
-
|
I put together a small implementation prototype for this in a fork, since external PR creation appears to be restricted to collaborators right now. Branch: https://github.com/Dearli666/codex/tree/harden-secret-read-and-output-redaction What it changes:
Validation I ran locally: The focused |
Beta Was this translation helpful? Give feedback.
-
|
The key distinction is:
If a file is readable by Codex or by a subprocess Codex starts, then its contents can indirectly reach the model through stdout/stderr, summaries, test failures, A practical setup is to put a custom permission profile in default_permissions = "safe-workspace"
approval_policy = "on-request"
[permissions.safe-workspace.filesystem]
glob_scan_max_depth = 4
":minimal" = "read"
# Optional, but many build/test tools need temp space.
":tmpdir" = "write"
":slash_tmp" = "write"
# Common home-level secrets.
"~/.ssh" = "deny"
"~/.aws/credentials" = "deny"
"~/.azure" = "deny"
"~/.config/gcloud" = "deny"
"~/.netrc" = "deny"
[permissions.safe-workspace.filesystem.":workspace_roots"]
"." = "write"
# Repo-local secrets.
".env" = "deny"
".env.*" = "deny"
"**/.env" = "deny"
"**/.env.*" = "deny"
"**/*.pem" = "deny"
"**/*.key" = "deny"
"**/id_rsa" = "deny"
"**/id_ed25519" = "deny"
"**/.npmrc" = "deny"
"**/.pypirc" = "deny"
"**/.netrc" = "deny"
"**/secrets" = "deny"
"**/secrets/**" = "deny"
[shell_environment_policy]
inherit = "core"
ignore_default_excludes = false
exclude = [
"AWS_*",
"AZURE_*",
"GITHUB_*",
"OPENAI_API_KEY",
"*TOKEN*",
"*SECRET*",
"*PASSWORD*",
"*PASS*",
]Then start a new Codex session and verify the boundary: cat .env
rg --hidden --no-ignore "TOKEN|SECRET|PASSWORD|OPENAI_API_KEY" .Those should fail or be unable to read the denied files. For organizations, the stronger version is to enforce deny-read requirements centrally so users cannot weaken them locally, for example: [permissions.filesystem]
deny_read = [
"/**/.env",
"/**/.env.*",
"~/.ssh",
"~/.aws/credentials",
"~/.azure",
"~/.config/gcloud",
"~/.netrc",
]A few important caveats:
So the short answer is: ignored files are not enough. Use sandbox permission profiles or managed deny-read requirements for secrets. That is the right layer to prevent |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
During testing with Codex CLI, I noticed an important nuance regarding how ignored files are handled:
@(e.g.@config/settings.py), files listed in.gitignoreare not included in the model context — which is great.rg,cat, or other workspace-wide searches, those same ignored files can still be read locally and their contents may appear in Codex responses.This raises some uncertainty about how to safely handle sensitive information (like
.envfiles, credentials, or local configs) that might be present in the workspace but should never be exposed to the model or remote context.Questions
rg,cat, search, or summarization commands)?.gitignoreor.envpatterns)?Why this matters
In practice, developers often have secrets or credentials stored in
.env,.json, or config files within the same repository.Even if those files are ignored by Git, it’s unclear whether Codex might still read them locally when using tools like
rgor global context searches.It would be extremely helpful to have:
Thanks for clarifying this — it’s key for safely using Codex in real development environments.
Beta Was this translation helpful? Give feedback.
All reactions