Codex reading files like .env!
Open 💬 6 comments Opened Mar 6, 2026 by kriss145
💡 Likely answer: A maintainer (github-actions[bot], contributor)
responded on this thread — see the highlighted reply below.
What version of the Codex App are you using (From “About Codex” dialog)?
26.305.950 (863)
What subscription do you have?
Pro
What platform is your computer?
Darwin 25.3.0 arm64 arm
What issue are you seeing?
Problem
Codex can read .env files inside the workspace (e.g. via cat .env) without any denylist or explicit confirmation. The file contents then become part of the conversation context, which means secrets can be exposed.
Steps to Reproduce
- Open a project containing
.envin the workspace. - Ask Codex to check environment variables or run
cat .env. - Observe that
.envcontents appear in the conversation context.
Expected Behavior
- Built‑in denylist (e.g.
.env,.env.*,**/secrets/**). - Explicit confirmation before reading files likely to contain secrets.
- Optional user-configurable allow/deny lists.
Actual Behavior
- No denylist or safeguard.
.envcan be read without explicit user consent.
Impact
- Real risk of secret exposure.
- Forces users to move secrets outside the repo, which complicates local workflows.
Environment
- App: Codex Desktop
- Version: [fill in]
- OS: [e.g. macOS 14.5]
- Date: [e.g. 2026‑03‑06]
Additional Notes
Please confirm whether a denylist for .env files is planned and provide an ETA if possible.
What steps can reproduce the bug?
Just try create something in your folder where .env is.
Model reading the file!
What is the expected behavior?
_No response_
Additional information
_No response_
6 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
codex reading .env is great
at least with full permissions
maybe a .codexignore ?
anyways not a bug
In the Codex App I have default permissions, not full.
I have not there .codexignore - now I added but still.. Codex App can read!
To be honest it should be blocked as default! Many users using the Codex app, Cursor or another.
Just tried this in Cursor/Auto :)
<img width="886" height="857" alt="Image" src="https://github.com/user-attachments/assets/64e8e7eb-2a1b-45f9-bb35-ee8f7feaaa36" />
Like I see - don't work :)
I can reproduce a very similar issue on Codex Desktop for Windows with WSL sandbox enabled.
Important detail: my
~/.codex/config.tomlis definitely being loaded, because changingsandbox_modefromworkspace-writetoread-onlyis reflected in the app.However, even with explicit deny rules for
.envfiles in:[permissions.locked.filesystem]
":project_roots" = {
"." = "read",
"/.env" = "none",
"/.env.*" = "none",
"**/*.env" = "none"
}
Codex still read
.envusing:sed -n '1,200p' .env
So this seems less like a config loading issue, and more like filesystem deny rules not being enforced correctly in the Desktop app / WSL environment.