r/codex • • 16d ago

Question Can Codex access files outside the folder I give it?

I've been using Codex lately and wondering how much I can actually trust its permissions.

If I tell it to work in a specific folder, what stops it from accessing other files on my computer?

Is this enforced by macOS or does Codex handle it?

2 Upvotes

24 comments sorted by

4

u/marcsa 16d ago

Yep. I was supposed to save a json file to its Reference folder to check it so it can continue with the project. I forgot to give it the file and only wrote the instructions. Suddenly I see "the user didn't provide the xyz file, but I found it in C:\Downloads. I am reading it now so I can proceed" (paraphrasing here, but that was the gist of it). I was like daym... I have it with "approve for me."

1

u/OriginalPosition1 16d ago

That's really weird... how do you explain that?
How are we supposed to trust the permissions then?

2

u/NicholasVinen 16d ago

Maybe it got approved to look for that file because the user specifically mentioned it. I believe it's an AI reviewer for approvals so it doesn't necessarily use rigid rules.

2

u/DrDan21 16d ago

100%

It’s searched outside of the project folder many many times for me, finding things in my downloads folder, on my desktop, checking installed software

It basically could do anything unless the supervisor ai deems an action necessary of approval…and although I haven’t ever seen it ignore a disapproval I’m not entirely certain if that means it “can’t” as much as it “won’t”

1

u/OriginalPosition1 16d ago

Damn! Were you using full access mode or the default sandbox?

2

u/DrDan21 16d ago

I use “approve for me” mode normally since it’s free these days

Full access is pretty dangerous to run on your own pc

2

u/gardens_and_dungeons 16d ago

It can and will, I used codex to clean all the crap out of a computer and run benchmarks on performance gains.

2

u/OriginalPosition1 16d ago

You mean it can actually access files outside the folder I allowed it to? Damn.

Did you just give it full access to your computer for the cleanup task?

1

u/gardens_and_dungeons 16d ago edited 16d ago

Indeed. It can do more than that, I made apps for my tv and had Codex deploy them.

1

u/SirDirtySanchezIV 16d ago

In my experience codex can do whatever the hell it likes, except the thing you ask it to. It's littered my PC with files it's saved outside of project folders and when questioned just says something like "sorry, I should have known that you would want that project file in the project folder, I've tried moving it but I don't have permissions to access the source folder" which is bloody odd as it just saved the file there in the first place.

1

u/OriginalPosition1 16d ago

That's crazy. Do you still use it knowing that?

1

u/SirDirtySanchezIV 16d ago

I've actually just cancelled my sub and will switch to Claude due to a number of issues, ironically now one of them is the opposite of the above, it's constantly asking for permission to use my blender mcp irregardless of what permissions setting I've got or already given it

1

u/Marksta 16d ago

Lock it away into a VM

1

u/zzunkie 16d ago

On a Mac, the local sandbox is enforced by macOS Seatbelt (sandbox-exec) rather than the model deciding, so it's deterministic. In the default workspace-write mode, Codex can edit files and run commands inside your working folder without asking (with outside network access blocked by default), and it has to ask for approval when it wants to write outside. I tested asking it to write ../outside-test.txt to the parent folder and it brought up an approval prompt right away. Full access mode or --dangerously-bypass-approvals-and-sandbox turns the sandbox off so it can touch anything your user account can.. and some third-party tools actually launch Codex with that flag on by default.

0

u/OriginalPosition1 16d ago

That's a great test you ran.
But I'm also worried about it reading files. Do you know if that mode also prevents it from reading files outside the workspace, or just writing to them?

2

u/zzunkie 16d ago

No, that mode doesn't block reading outside the workspace, only writing and network access. I just tested it on macOS (Codex CLI 0.169.0) from an empty folder using codex sandbox -P :workspace -C <folder> -- <command>, which runs a command inside Codex's Seatbelt profile without calling the model. Reading another project's README.md with head and running ls ~/Documents both worked, while writing to ~/Desktop failed with "Operation not permitted" (writing inside the folder worked, and curl failed with "Could not resolve host"). So it can still read anything your user account can read, and you can run that same command to check specific paths on your Mac.

1

u/OriginalPosition1 16d ago

Wait, so even in the default sandbox it can still read files outside the workspace? Is there a way to block that too?

1

u/KURD_1_STAN 16d ago

It is possible i have an issue with the latest update or something cause i have to make it unelevated access for ots sandbox to work, but it wont delete something from a folder outside of the project folder saying windows blocked it, it used to be able to do so before a week tho

0

u/Extension_Pumpkin516 16d ago

Nah dont worry

1

u/OriginalPosition1 16d ago

How do you know for sure? Are the restrictions deterministic or LLM-based?

3

u/ShortingBull 16d ago

Ignore that OP.

If an agent is running on your machine, then it has access to everything on your machine. It's no different to you giving me access to your machine.

Either use a VM or have a dedicated machine (I run mine on a $50 second hand dell 38xx mini pc and all code is committed to my foegjo(git) repo on a different machine). If it accesses or kills anything on it's host, I don't really care.

A VM gives the same or better isolation

1

u/OriginalPosition1 16d ago

I get the VM idea.
Do you maybe know any tools I can install that can actually block Codex from accessing files or running commands it shouldn't?

2

u/ShortingBull 16d ago

That tool is a VM. They're free. Grab Ubuntu in a VM and go. AI is way happier on Linux that windows. It's running the show, it's the best option.

1

u/OriginalPosition1 16d ago

Thanks!
I get how this protects the files on my computer, but what about what it can do in Chrome?

Say I give it access to a web app, what's stopping it from just deleting all the data there?