Codex CLI Security-First Installation

Installing an AI coding agent without compromising security or privacy.

Artificial intelligence is changing how we build software, manage infrastructure, and solve technical problems. As someone interested in cybersecurity, privacy, and automation, I see enormous potential in these tools. But enthusiasm for new technology shouldn't require abandoning skepticism.

That philosophy shaped my recent installation of OpenAI's Codex CLI on a Kali Linux workstation. Rather than installing the application and immediately giving it access to my website and server, I treated the setup as a security exercise.

The Vibe-Coding Debate: Convenience Versus Competence

I'm familiar with the ongoing debate about vibe coding: relying on AI to generate software, sometimes without fully understanding the resulting code. I understand the criticism. Generated code can contain security vulnerabilities, logic errors, unnecessary dependencies, and maintenance problems. If the person deploying it cannot evaluate what was generated, those problems can become production risks.

But I don't think the answer is to dismiss AI-assisted development. There's a meaningful difference between outsourcing technical judgment and using AI to accelerate work while retaining responsibility for it.

I don't need to personally type every line of code. I do need to understand the desired behavior, evaluate important implementation decisions, test the result, and recognize when something requires deeper investigation.

AI can accelerate development. It cannot eliminate the need for technical judgment, testing, or accountability.

Better Instructions Produce Better AI Outcomes

I also think many people who rush to adopt AI tools underestimate how much the results depend on the instructions they provide.

Within the capabilities of a given model, an AI tool's usefulness often increases with the specificity, clarity, and relevance of the user's instructions. That's not a mathematical law, and longer prompts aren't automatically better. What matters is whether the AI knows the objective, relevant context, constraints, and definition of success.

Compare these requests:

Help me build my website.

Versus:

Review the existing Joomla website on an Ubuntu VPS. Preserve Apache configuration, certificates, and staging boundaries. Inspect the template and page-builder structure before suggesting edits. Do not change production files without approval. Explain the risks and provide a rollback plan.

Both ask for website help. Only the second defines what success—and safe behavior—looks like.

There is one crucial distinction, though: instructions describe what an agent should do; technical controls determine what the system actually permits it to do. A carefully written prompt is not a firewall, a permission boundary, or a sandbox.

A Privacy-Focused Security Advocate Using Codex?

It can seem counterintuitive for a security-minded, privacy-focused technology evangelist to install an AI coding agent capable of running commands. Why place such a tool on a workstation used for security research, penetration testing, and system administration?

That's exactly why I approached the installation this way.

Security advocacy doesn't require rejecting technology. It means understanding the risks, evaluating the tradeoffs, and putting appropriate controls in place before enabling capabilities. My Kali workstation has personal files, administrative tools, authentication material, and unrelated projects. A website-development assistant doesn't need access to them.

I wanted to explore Codex's capabilities without handing it the keys to everything else.

1. Start With a Threat Model

Before installation, I considered what would be exposed if the agent inherited the permissions of my daily-use Linux account:

  • SSH keys and remote authentication material
  • Browser profiles and saved application sessions
  • Personal files and unrelated development repositories
  • Mounted network storage and backup repositories
  • Administrative utilities and system configuration
  • Environment variables that might contain secrets

The concern was not that Codex was inherently malicious. The concern was unnecessary access, accidental changes, and the possibility of malicious instructions arriving through untrusted source files or other content—a problem often described as prompt injection.

The objective was simple: grant only the access needed for the website task, and expand it deliberately if justified.

2. Establish a Dedicated Linux Account

Rather than running Codex under my ordinary workstation identity, I created a separate, non-administrative account with its own home directory and application configuration. We reviewed the account's group membership and access to sensitive areas, including personal network storage.

This reduces exposure to files and credentials owned by my daily-use account. It is not the same isolation guarantee as a dedicated virtual machine, and ordinary Linux account boundaries still depend on correct file permissions and system configuration. It is one layer of defense, not the whole design.

3. Inspect and Verify the Installation

The installation was approached as a supply-chain verification exercise rather than a blind copy-and-paste command. We used restrictive file-creation permissions, inspected the downloaded installer, reviewed release material, and verified the downloaded executable using SHA-256 and Cosign signature verification.

The release installed during this exercise was Codex CLI 0.167.1. The checks performed during the setup passed.

A checksum alone is not proof of authenticity if the reference checksum comes from an untrusted source. Signature verification adds useful provenance assurance when the signing identity and source are checked appropriately.

4. Keep Authentication Out of Ordinary Credential Files

We configured Codex to use GNOME Keyring for authentication storage, initialized a D-Bus session for the dedicated user, and checked that the ordinary auth.json credential file was not created.

The relevant setting was:

cli_auth_credentials_store = "keyring"

A keyring improves credential handling, but does not render credentials inaccessible to the legitimate authenticated process. The account and runtime environment still need protection.

5. Start With Restrictive Sandbox Defaults

The initial configuration used read-only behavior and approvals for requests that needed to cross the configured boundary:

sandbox_mode = "read-only"
approval_policy = "on-request"
web_search = "disabled"

We also launched the application with explicit options for sandbox and approvals:

codex --no-daemon --strict-config \
  --sandbox read-only \
  --ask-for-approval on-request

Disabling the web-search feature is not the same as proving that all network access is blocked. Network behavior must be tested independently. Likewise, instructions in a project file are not an enforceable permission boundary.

6. Verify the Boundaries, Don't Just Trust the Settings

We tested a representative filesystem write operation and an outbound network socket operation within the restricted runtime.

  • Test write operation: denied.
  • Test outbound socket operation: denied.

These results provided evidence that the tested restrictions were operating as intended. They do not establish that every filesystem path, network path, subprocess, or potential sandbox escape was comprehensively assessed.

A successful control test supports a specific claim; it is not proof of universal security.

7. Prepare for a Controlled Joomla Workflow

The agent's intended job is to assist with a self-hosted Joomla website using Apache, Helix Ultimate, and SP Page Builder. We prepared project-specific guidance in an AGENTS.md file and planned a gradual workflow: read-only inspection, review of staging boundaries, isolated edits, human approval, and rollback-capable deployment.

The next security checks include a deeper review of process isolation, credentials and environment exposure, writable-directory boundaries, staging access, and repeatable startup and shutdown procedures.

Importantly, the baseline Codex installation was tested; unrestricted remote website modification was not authorized by those tests.

8. What We Verified

Control Outcome from initial setup
Dedicated non-sudo account Verified
Separation from personal NAS shares Verified in the reviewed configuration
Installer inspection Completed
SHA-256 and Cosign verification Passed
GNOME Keyring credential storage Configured
Default auth.json absence Verified
Read-only sandbox Configured
Representative file write Denied
Representative outbound socket Denied
Project instructions Prepared
Full remote staging and writable-boundary review Still pending

These are observations from the initial exercise, not an independent penetration test or a guarantee that the environment is immune to every attack.

9. Curiosity and Discipline Are Not Opposites

I can be optimistic about AI's potential and still take its limitations seriously. I can appreciate AI-assisted development while recognizing the hazards of deploying code I don't understand. I can give an agent precise instructions without confusing those instructions for enforceable controls.

The point of this project wasn't to prove that Codex is perfectly safe or that AI coding has no legitimate critics. It was to adopt a useful new capability without abandoning established security practices.

My goal isn't to have AI do my thinking for me. It's to extend what I can accomplish while remaining responsible for the results.

And if securing the environment takes extra effort before writing the first line of website code, that's time well spent.


Merlin's Corner: The Backyard Rule

Merlin wearing a wizard hat introducing Merlin’s Corner

Security lessons explained by a dog who knows which doors should stay closed.

Hi, Merlin here.

Apparently, my human wants to invite someone over to teach me new doggie tricks. I'm all for it. Especially if treats are involved.

But just because somebody is coming over to help me learn doesn't mean they need access to the entire house.

They can come into the backyard. There's plenty of room to practice sitting, staying, rolling over, and pretending I didn't hear the word “stay.”

They don't need to wander into the bedrooms, open the kitchen cabinets, investigate the closets, or explore the garage. And they definitely don't need their own key to the front door.

If we decide to practice an indoor trick later, my human can open the right door when we're ready.

That's how we set up our new AI helper. We gave it a specific place to work, limited where it could go, and tested the boundaries before asking it to do anything important.

Merlin's security lesson: Give your helpers access to the backyard, not the entire house. Open another door only when there's a good reason.

Now, about those treats.


Further Reading