All integrations

    Integration: Codex

    How do I secure OpenAI Codex?

    Updated

    Short answer

    Keep Codex in its workspace-write sandbox with on-request approvals, block full-access mode in managed configuration, and check every action before it runs. Codex rules match command prefixes and are experimental, and OpenAI calls its hooks a guardrail, not a complete enforcement boundary. Harden AIF connects to Codex's PreToolUse hook and checks each action on the developer's machine before it executes.

    What Codex can do on a developer's machine#

    Codex reads your repo, writes patches and runs commands to test them. Depending on how it's configured, it can:

    • run shell commands, including ones that leave the sandbox after an approval or an allow rule;
    • edit files through apply_patch;
    • call MCP tools and search the web, where OpenAI warns that prompt injection can make it fetch and follow untrusted instructions;
    • in danger-full-access mode, do all of that with no sandbox and no approvals.

    What Codex's own controls do, and what they miss#

    • The sandbox confines spawned commands, not only file edits, and by default network access is off. Developers can switch it off with --dangerously-bypass-approvals-and-sandbox (alias --yolo).
    • Approval policies decide when Codex stops to ask. Every prompt is a person deciding under time pressure, one command at a time.
    • Rules allow, prompt or forbid commands by prefix. The docs say "Rules are experimental", and a complex shell script (pipes, substitution, control flow) is judged as one invocation.
    • Managed configuration lets admins forbid full access and pin approval settings. Good. It sets limits; it doesn't judge each action.
    • PreToolUse hooks can intercept Bash, apply_patch and MCP calls and deny them. OpenAI's own hooks page says to treat them as "a useful guardrail, not a complete enforcement boundary".

    What Harden AIF checks before each Codex action#

    AIF is a separate service on the developer's machine. Codex calls it through its PreToolUse hook before each action runs, so the check sits outside the agent and its context window. For each pending action, it:

    • parses the command into a syntax tree and follows each value from its source to where it ends up, so a secret headed for a network call gets blocked however the command is written;
    • judges secrets by their content, not their file name;
    • checks destructive commands (recursive deletes, force-pushes to the default branch, piping curl into a shell, disk wipes) against where they actually run;
    • decodes base64 and hex before it decides, and sends dynamic code it can't resolve to a human;
    • fails closed: if the check can't run, the action doesn't run.

    When it blocks, the agent gets the reason and can retry a safe way. Every decision is recorded, and you can export the records to your SIEM.

    Where Codex accepts a rewritten call, Harden can fix it instead of refusing it.

    How to set up Harden for Codex#

    These steps come from the Harden docs.

    1. Install AIF with curl -fsSL https://aif.harden.run/install.sh | sh, then open a new shell.
    2. Connect Codex with aif configure --agent codex --validate.
    3. Run aif status to check protection, the local model and activity history.
    4. Run aif demo for a safe demo, and aif show to open the local decision history.

    For a fleet, follow the enterprise setup guide: create the organization, make an enrollment profile, push the package through your MDM and verify a pilot device. Start in shadow mode, so your team sees what agents do before anything gets blocked.

    FAQ

    Questions about Codex

    Is Codex safe in full-access mode?

    Not on a machine with real credentials. OpenAI lists danger-full-access as no sandbox and no approvals. Admins can forbid it in managed configuration, and every action should still pass a check before it runs.

    Do Codex rules stop dangerous commands?

    They help with commands you can name. OpenAI's docs say rules are experimental and compare the command's arguments to a pattern, so a complex shell script is judged as a single invocation. A check that parses the script sees what it actually does.

    Can Harden rewrite a Codex action instead of blocking it?

    Yes, where Codex accepts a rewritten call. Harden can redact a secret and let the safe version run, or block the action and give Codex the reason so it retries a safe way.

    Sources

    1. Codex docs: Approvals and security
    2. Codex docs: Sandboxing
    3. Codex docs: Rules
    4. Codex docs: Hooks
    5. Codex docs: Managed configuration
    6. Harden docs: Configure an agent

    Start free at harden.run

    Full Enterprise access, free for 60 days, when you sign up by Dec 1: unlimited developers, custom policies, centralized visibility, no commitment.

    Other agents: see every integration.