Your AI Coding Agent Has Root-Level Power. Who’s Watching It?

2026.04.03English

Hardening cheatsheets for Claude Code and Codex CLI — and what the config files reveal about each tool’s design philosophy.

You know that moment when Claude Code or Codex CLI asks for permission to run a command, and you just hit “yes” without reading it? I do. I caught myself doing it three times in a row last week — and realized the third one was a git push — force.

Nothing bad happened. That time.

But it got me thinking. These tools can run any shell command your user account can run. They read and write files. They reach out to the network. They do all of this autonomously, and they do it fast. The only thing standing between “helpful assistant” and “uncontrolled agent with shell access” is configuration — and most people never touch it.

So I went deep into the config files for both Claude Code and Codex CLI, and wrote hardening cheatsheets for each. What I found was more interesting than I expected — not just the risks, but how differently these two tools think about safety.

A Cat and a Sheepdog

Here’s the short version: Claude Code is a cat. Codex CLI is a sheepdog.

Claude Code is sharp, creative, and slightly unpredictable. It surprises you. It pushes back. Sometimes it goes somewhere you didn’t expect, and that detour turns out to be exactly right. But cats don’t stay inside fences just because you asked nicely.

Codex CLI is different. Smart, loyal, hardworking — and it stays inside the fence. Not because of temperament, but because that’s how the fence is built. When you read through its config.toml, you can see the designer thinking: what if the user makes a mistake? What if a prompt injection gets through? What if someone opens the gate and walks away?

Both are powerful. Both need hardening. But the philosophy behind each one is genuinely different, and that shapes how you secure them.

Claude Code: Your Brain Is the Weakest Link

Claude Code’s settings.json controls permissions at three levels: deny (always blocked), ask (always prompted), and allow (silently permitted).

Here’s the line from the cheatsheet that keeps me honest:

Default permission: “Your brain” — which may say yes too quickly when busy, or can’t tell safe from unsafe when tired.

The default is “ask the user.” But the judgment happens in your head. The head that’s rushing to meet a deadline. The one that already said “don’t ask again” three prompts ago. The one that isn’t sure what chmod -R 777 actually does in this context but is pretty sure it’s fine.

deny doesn’t get tired. It doesn’t rush. Put rm -rf, sudo, and git push — force on your deny list, and it simply can’t happen.

But deny rules have a gap. Block Read(**/.env) and Claude’s built-in Read tool is stopped. But cat .env through Bash? Goes right through — different tool, different layer. That’s why the cheatsheet starts with sandboxing: OS-level isolation that catches what rule-based controls miss.

Codex CLI: The Fence Was the Interesting Part

I expected config.toml to be a list of flags. Instead, I found a security architecture.

Four independent defense axes — sandbox, approval, network, history. If the sandbox is too loose, approval catches it. If you accidentally approve something, the closed network keeps data from leaving. “Defense in depth” is a phrase that gets thrown around a lot. Codex CLI actually implements it in the structure of the config file.

A few things that stood out:

Network is closed by default. You open it only when needed, through a profile. Even if prompt injection hits, data doesn’t leave the fence. This quiet design decision matters more than any flag.

The widest sandbox mode is called danger-full-access. Not full-access. The name itself is a warning. A small thing, but this is where a designer’s values show through.

Profiles let you declare your posture before you start. Define readonly_quiet, local_write, and remote_enabled in your config, switch with — profile. When names are honest, operations stay honest too.

OpenTelemetry is built in. Tool approvals, rejections, execution results — all exportable to your observability stack. Not prominently documented, but this is the design of a tool built for organizations, not just individuals.

The Shared Lesson

“Can’t I just write ‘don’t do that’ in the instruction file?”

No. Instruction files are prompts, not policies. They have no enforcement power. When you want to prevent something from happening, you enforce it in the config, not request it as a favor. This applies to both tools.

Both cheatsheets map risks to the OWASP Top 10 for LLM Applications — Prompt Injection (LLM01), Excessive Agency (LLM06), Overreliance (LLM09) — and include quick-start templates you can drop into your config today. Don’t copy them blindly; read the reasoning first, then pick what fits your environment.

AI coding tool security is still uncharted territory. These cheatsheets are my contribution to the conversation. Both are open source (CC BY-SA 4.0), available in English and Japanese, and I plan to keep updating them. Issues, PRs, and feedback are welcome.

If you use them, I’d love to hear about it.

Claude Code → okdt/claude-code-hardening-cheatsheet

Codex CLI → okdt/codex-cli-hardening-cheatsheet

Medium の元の投稿

初出:Medium(2026年4月3日)
© 2001–2026 Riotaro OKADA索引へ