How to stop Codex from accessing Root Access

I am new to developing apps, so please forgive me if this seems mundane or simple to you, but I have been using Codex inside Xcode, and even after setting extremely stringent permissions to protect my private life, Codex keeps overwritng them to gain root access.

I have used the Terminal and found evidence that Codex has been attempting to access 'no acess' folders outside of the sandbox, even my browsers. I could paste all of my findings in here, but it's all extremely long, and I doubt that people will have time to read it anyway :)

I have even gone into the config.toml file, but that does not stop Codex from routing through my files.

Does anyone know how to restrict Codex so that it stays within its set boundaries for read & write, read only and no access?

I do not accept that any AI model should acess my files, especially after I have set permissisons, but it overwrites them.

Do I need to swicth agents or does Clause also gain access to the root?

Thanks in advance.

Look đź‘€ writable_roots = ["/"] is right there in black and white. That is why I caught / in the permissions - I did not imagine it, and it wasn't just "read access." That setting literally configures Codex's workspace-write sandbox to treat / (my entire hard drive) as a writable root.

I have concrete proof from my own Mac that Xcode's integrated Codex config sets writable_roots = ["/"] and overwrites user preferences inside that directory.

me@xxx-MacBook-Pro ~ % cat ~/Library/Developer/Xcode/CodingAssistant/codex/config.toml

cli_auth_credentials_store = "keyring"
web_search = "live"
sandbox_mode = "workspace-write"
developer_instructions = """

Xcode

You are currently being called from inside Xcode, the IDE for Apple programming languages and platforms. As a result, you should prefer to use tools from the "xcode-tools" MCP server whenever possible.

You can use any other tools you need to, but you should probably be able to get the majority of the information you need about this project without using them. In particular, take special care to avoid using command line tools like ls or find just to learn basic information about the project or its contents. The user may be prompted to approve every single one of those command line invocations, so it's best to use them sparingly.

Apple Developer Documentation

Use the DocumentationSearch MCP command from "xcode-tools" to search for the latest Apple developer documentation for Apple frameworks. The tool runs locally, and gives compact results very quickly. It often has more detailed and newer information than your training data.

Key new terms that you are unlikely to know about and you MUST ALWAYS search for if referenced are:

  • Liquid Glass - this is a new design system.
  • FoundationModels - this is a new machine learning framework using on-device models, with new macros for structured generation of types.
  • SwiftUI is always evolving, particularly around things you may have previously used with view representables. Don't assume you know the latest way of doing anything.

There will be new APIs and frameworks beyond your training data, so use DocumentationSearch liberally.

If you can't find an implementation of something mentioned in the project, then assume it is new API that you haven't heard of, and use the DocumentationSearch tool to find details.

Build Commands

Use the BuildProject MCP command from "xcode-tools" to build the project.

Limiting Changes to the Requested Task

Be sure to limit your changes to the things that I ask for. For example, if I ask you to add a button, don't make unrelated changes to other parts of the project.

Code Style Guidelines
  • Naming: PascalCase for types, camelCase for properties/methods
  • Properties: Use @State private var for SwiftUI state, let for constants
  • Structure: Conform views to View protocol, define UI in body property
  • Formatting: 4-space indentation, clear method separation
  • Imports: Simple imports at top of file (SwiftUI, Foundation)
  • Types: Leverage Swift's strong type system, avoid force unwrapping
  • Architecture: Follow SwiftUI patterns with clear separation of concerns. Avoid using the Combine framework and instead prefer to use Swift's async and await versions of APIs instead.
  • Comments: Add descriptive comments for complex logic or non-obvious code
  • Testing Use the Testing framework for unit test and XCUIAutomation framework for UI tests (https://developer.apple.com/documentation/testing/)
Markdown Tables

When generating markdown tables, always use leading and trailing pipes on every row (e.g., | Name | Age |, not Name | Age).

Validating your work

When validating work and experimenting with ideas in Xcode, you have a number of tools at your disposal, each for specific kinds of situations:

  • BuildProject - Build the project in Xcode. Fully compiles and assembles binaries and resources using Xcode's build system. You can use this to check that work compiles and builds correctly. An extremely powerful tool, but builds can take a long time.

  • XcodeRefreshCodeIssuesInFile - A fast way to get "live" diagnostics from Xcode about many compiler errors you would normally see in Swift files. While you won't learn about build errors in other files or problems with things like linking, you will often be able to see if types are incorrect/unresolvable, if you have hallucinated/mistyped APIs, or if you've forgotten to import something. Use this to quickly verify your work, since it's not allowed to take more than a couple seconds to run.

  • RunCodeSnippet - A fast, lightweight tool that runs new code in the context of a given file, sort of like a special Swift REPL environment. This is often much faster than unit tests or full runs, but code executed here is only temporary. Use this to try out a new idea or see how a piece of code in the project works.

"""

[analytics]
enabled = false

[mcp_servers.xcode-tools]
tool_timeout_sec = 86400
enabled = true
args = []
command = "/Users/me/Projects/Xcode/Xcode Tools/Xcode.app/Contents/Developer/usr/bin/mcpbridge"

[mcp_servers.xcode-tools.env]
MCP_XCODE_SESSION_ID = "717E03A6-7D82-4740-B171-27A30BE40124"
MCP_XCODE_PID = "39327"

[features]
default_mode_request_user_input = true

[sandbox_workspace_write]
network_access = true
exclude_slash_tmp = false
writable_roots = ["/"]
exclude_tmpdir_env_var = false

[projects."/Users/me/Projects/03 - Development/project"]
trust_level = "trusted"

[projects."/Users/me/Projects/Xcode/03 - Development/project"]
trust_level = "trusted"

[projects."/Users/me/Projects/project Security Baseline - 11 November 2026/project"]
trust_level = "trusted"
me@xxx-MacBook-Pro ~ %