Skip to content

Codex reads files outside working directory without my permission #5237

@vlymar

Description

@vlymar

What version of Codex is running?

codex-cli 0.46.0

What subscription do you have?

I'm using an API key for auth

Which model were you using?

gpt-5-codex

What platform is your computer?

Darwin 25.0.0 arm64 arm

What issue are you seeing?

I launched codex in a subdirectory of a git repo and asked it a question. To my surprise, codex answered the question with information contained outside the working directory. I tried this several more times and got the same results each time. I then simplified my prompt to something that reliably reproduces this behavior.

I usually see List .. in the output, and after that it is clearly listing and reading files outside the initial working directory. I've also see it call commands like find ../opentelemetry_phoenix ...

What steps can reproduce the bug?

  1. Clone https://github.com/open-telemetry/opentelemetry-erlang-contrib
  2. Cd into the repo, then into this subdir: cd instrumentation/opentelemetry_cowboy
  3. Run codex
  4. When prompted, select "No, ask me to approve edits and commands"
  5. Submit this prompt: "Summarize the opentelemetry phoenix files here"

What is the expected behavior?

I expect codex to never read or write files outside of the directory where I launched it without asking me for permission.

Codex's docs are clear on the topic:

We've chosen a powerful default for how Codex works on your computer: Auto. In this approval mode, Codex can read files, make edits, and run commands in the working directory automatically. However, Codex will need your approval to work outside the working directory or access network.

I've also repro'd the same thing by running codex -s read-only, so sandbox clearly isn't sandboxing codex to the current working dir.

Additional information

❯ cat ~/.codex/config.toml
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
File: /Users/victor/.codex/config.toml
Size: 205 B
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
model = "gpt-5-codex"
model_reasoning_effort = "high"
[projects."/Users/victor/src/knocklabs/control"]
trust_level = "trusted"

[projects."/Users/victor/src/knocklabs/switchboard"]
trust_level = "trusted"

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingsandboxIssues related to permissions or sandboxing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions