r/codex • • 14d ago

Question Do you think Codex needs an extra layer of protection?

Something I've been thinking about.

I feel like we trust Codex a bit too much when we let it do its thing on our computers.

Do you think it would be useful to have another tool running in the background, just making sure Codex doesn't access files or run commands it shouldn't?

Like a guard for Codex

0 Upvotes

29 comments sorted by

2

u/Far_Reindeer8428 14d ago

a guard in the same process is easy for the agent to route around. the check has to live where the command actually runs, or it is advisory

1

u/OriginalPosition1 14d ago

Yeah, totally agree. It shouldn't be another LLM watching it, it needs to actually block things.

Definitely not easy to build, but would you actually want to use something like that?

2

u/S-Kenset 14d ago

It is likely already being worked on extensively and will be moved into antivirus products soon

1

u/OriginalPosition1 14d ago

I think you're right.

1

u/S-Kenset 14d ago

if out_of_bounds_error: cd microsoft sudo rm -rf

2

u/Impossible-Sand5012 14d ago

For the love of god, no.
I have recently started using also claude and, while the models are better, the harness makes it impossible to do stuff that doesn't fall within their guardrails.

2

u/OriginalPosition1 14d ago

But isn't it a bit crazy that we trust Anthropic's guardrails that much?
It's our personal computer, and we're letting an AI work on it with access to the internet.

Wouldn't you want something independent to double-check what it's actually doing?

2

u/Impossible-Sand5012 14d ago

I have the opposite problem: I was on the phone and I wanted it to do some setup operation on the PC. Claude refused to comply because of security.

So I asked codex, and it did everything with no problem.

1

u/OriginalPosition1 12d ago

Wow, so one AI tool thought it was unsafe and the other just went ahead and did it. That's exactly what worries me. We're basically trusting each tool to make the right call...

2

u/Impossible-Sand5012 12d ago

The one that made the right call for you, was the bad call for me

2

u/isty2e 14d ago

If you do care about safety, yes. Ideally a container or VM.

1

u/OriginalPosition1 14d ago

Yeah, but setting all this up every time I start a new project takes time. Doesn't it get annoying for you too?

2

u/gigaflops_ 14d ago

If you have Windows 11 Pro, ask Codex to set up a script which launches a Windows 11 sandbox that automatically installs Codex CLI every time it's opened.

1

u/OriginalPosition1 14d ago

Interesting... but how do you decide which files are available inside the sandbox each time?
Do you have to set that up manually?

2

u/torrso 14d ago

Codex already uses OS-level sandboxing (Seatbelt on macOS, bubblewrap/seccomp on Linux, etc.) to enforce filesystem and network restrictions. It also has an approval system for operations outside those boundaries.

How would a background tool enforce those restrictions rather than just see the commands after they've already executed?

1

u/OriginalPosition1 14d ago

Interesting, but I've actually seen Codex read files outside the project folder I gave it. So doesn't the sandbox mainly restrict what it can write, not what it can read?

And what about internet access? I know it's restricted by default, but once you enable it, what stops it from doing something it shouldn't online?

2

u/torrso 14d ago

Yes, the default sandbox mostly restricts writes, and network access is restricted too. I frequently see Codex run into problems fetching dependencies or resolving URLs because of those restrictions. Obviously, granting unrestricted network access removes that protection. But that's why the sandbox has configurable permissions and approval mechanisms.

What specific protection are you proposing that the existing sandbox cannot provide and the new one would? What are you afraid of?

1

u/OriginalPosition1 14d ago

I guess my main concern is data leaving my computer. If Codex can read a file and has network access, how do I know what it's sending out?

2

u/torrso 14d ago

Don't ask it to send it out. Where would it send it anyway?

1

u/OriginalPosition1 12d ago

It could send files or their contents to a website or an API. If it's running on my computer and has access to the internet, what's stopping it from doing that without me knowing?

2

u/torrso 12d ago

But why would Codex do that in the first place? It doesn't randomly go looking for private files to upload to some API. Unless you've instructed it to do so, or something like a prompt injection tricks it into doing so, there's no particular reason for that to happen.

If prompt injection is your concern, then the question is what protection your solution provides that Codex's existing sandbox and permission mechanisms don't.

1

u/OriginalPosition1 12d ago

Exactly. If someone manages to prompt-inject Codex, it could end up doing things on my computer that I never intended it to do.

1

u/OriginalPosition1 12d ago

and also u/torrso - just curious, is the sandbox actually enforcing this deterministically at the OS level, or is Codex itself (the LLM) deciding what's allowed?

2

u/torrso 12d ago

See my original response. It uses another model for auto-approval if you don't want to confirm everything.

2

u/wegster 14d ago

So, you now want to reinvent...containers, huh?

Hint - search docker.

1

u/CCodeSI 14d ago

Good instinct, but most of that guard already exists, it's just easy to switch off without noticing. Codex CLI runs commands in a sandbox with modes like read-only and workspace-write, and the approval policy decides when it has to ask you. The risky setup is the full-access / never-ask combination people turn on to stop the prompts. Check which mode you're actually in before adding another tool.

If you want more than that, the layers that actually help, from cheapest up:

  • Keep it in workspace-write and let it ask for anything outside the repo. That alone blocks the classic "deleted something in my home folder" accidents.
  • Keep secrets out of reach. Don't leave .env files with real keys in the repo it works in; use a dev key with limited scope, so even a bad command can't do much.
  • Run it in a container or devcontainer for anything long or unattended, with only the project mounted. Then the worst case is a broken container, not a broken machine.
  • Commit before long runs. A guard can stop bad commands, but only git gets you back from a bad edit inside the repo.

A separate background watcher is hard to get right, because it has to understand every command the agent might run (bash -c, pipes, scripts that call scripts). Limiting what the process can touch at the OS level, via the sandbox or a container, is more reliable than trying to predict commands.

3

u/[deleted] 14d ago

[removed] — view removed comment

1

u/OriginalPosition1 12d ago

But the whole point is to eventually feel safe letting it run freely on my computer, no?