Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Codex Security and Enterprise Management

Codex Security and Enterprise Management

Codex provides multi-layered security mechanisms and enterprise management features to ensure data security and support team collaboration.


Security mechanism overview

Codex's security design is divided into multiple layers:

Level Mechanism Purpose
Sandbox isolation Sandbox mode Restrict file and command access scope
Approval policy Approval Policy Control confirmation before operations are executed
Rule engine Rules Define command execution permissions
Network Control Network access settings Restrict external network access
Data protection Enterprise features Audit logs, data residency

Sandbox modes

Sandbox is Codex's core security mechanism, limiting the agent's operational scope.

Three sandbox modes

Mode File modification Command execution Network access Applicable scenarios
read-only Forbid Forbid Forbid Code review, analysis
workspace-write Workspace only Allowed Forbid Daily development (recommended)
danger-full-access Allowed Allowed Allowed Special scenarios (use with caution)

Set the sandbox mode

Sandbox configuration

Specify in CLI

codex

--sandbox

read-only

codex

--sandbox

workspace-write

codex

--sandbox

danger-full-access

Configuration file

[

mycode4

type

=

"toml"

]

~/.codex/config.toml

sandbox =

"workspace-write"

[/mycode4]

Sandbox boundaries

It is recommended to use workspace-write mode by default and only use danger-full-access when necessary.


Approval Policy

The Approval policy controls confirmation behavior before Codex performs actions.

Four Approval Modes

Mode Behavior Risk level
suggest Suggestions only, no actions performed Minimum
interactive Ask for confirmation before sensitive operations Low
auto-edit Automatically edit files; commands require confirmation Medium
full-auto Automatically execute all actions High

Set the Approval Policy

Approval Configuration

Specify via CLI

codex

--approval-mode

interactive

Switch During a Session

/

approval suggest

/

approval auto-edit

Configuration file

[

mycode4

type

=

"toml"

]

approval_policy =

"interactive"

[/mycode4]


Rules Engine

Rules uses the Starlark language to define command execution policies.

Rule types

Rule Description
prefix_rule Match command prefixes
glob_rule Match file path patterns

Decision types

Decision Behavior
allow Automatically approve execution
prompt Ask the user for confirmation
forbidden Forbid execution

Rule Examples

Rule definition

~/.codex/rules/default.rules

Allow Git commands

prefix_rule

(

    pattern

=

[

"git"

]

,

    decision

=

"allow"

,

    justification

=

"Git commands are safe for version control"

)

Allow npm install

prefix_rule

(

    pattern

=

[

"npm"

,

"install"

]

,

    decision

=

"allow"

,

    justification

=

"Package installation is expected"

)

Prohibit deleting the root directory

prefix_rule

(

    pattern

=

[

"rm"

,

"-rf"

,

"/"

]

,

    decision

=

"forbidden"

,

    justification

=

"Prevent system damage"

)

Ask about sudo commands

prefix_rule

(

    pattern

=

[

"sudo"

]

,

    decision

=

"prompt"

,

    justification

=

"Elevated privileges need review"

)


Network access control

Control Codex's network access capabilities to prevent data leaks.

Cloud Network Control

Stage Default Access Description
Setup scripts Allowed Need to Download Dependencies
Agent Execution Forbid Disabled by default, can be enabled

Domain Whitelist

Network configuration

Preset Whitelist

domain_allowlist = "common-dependencies"

Includes: github.com, npmjs.com, pypi.org

Custom Domains

domain_allowlist = [

    "github.com",

    "api.mycompany.com"

]

Restrict HTTP Methods

allowed_methods = ["GET", "HEAD", "OPTIONS"]

Security Risks

Risks that may arise from enabling Agent network access:

Only enable Agent network access when necessary, and restrict it with a domain whitelist.


Enterprise Management Features

The Enterprise plan provides enterprise-grade security and management features.

Enterprise Features Overview

Function Description
SCIM Automatic user provisioning
SAML SSO Single sign-on integration
MFA Multi-factor authentication
EKM Enterprise key management
RBAC Role-based access control
Audit logs Complete operation logs
Data residency Specify data storage regions

Managed Configuration

Enterprise administrators can distribute unified configurations.

Managed Configuration Priority

Configuration merge order:

  1. Managed configuration (distributed by the enterprise) - highest priority
  2. Project configuration (.codex/config.toml)
  3. User configuration (~/.codex/config.toml) - lowest priority

Managed Configuration Example

Enterprise Managed Configuration

Managed configuration distributed by the enterprise

Enforce sandbox mode

sandbox = "workspace-write"

Enforce Approval Policy

approval_policy = "interactive"

Disabled models

disabled_models = ["gpt-5.4-mini"]

Network whitelist

domain_allowlist = ["github.com", "internal-api.company.com"]

Audit Configuration

audit_logging = true


Audit logs

The Enterprise plan provides complete audit logging.

Log content

Record type Description
Session records Creation, modification, and deletion of each session
Tool call Detailed information on file reads/writes and command execution
Model calls API calls and token usage
User operations User authentication and permission changes

Log Access

Audit logs

Access audit logs through the enterprise admin panel

Can be exported as:


Data residency

Enterprise can specify data storage regions.

Residency Options

Area Description
United States The default locale
Europe GDPR compliance
Other regions Configured according to enterprise needs

Data residency settings require contacting the sales team to configure.


Team Management

User provisioning

SCIM configuration

Automatically manage users through an IdP (such as Okta or Azure AD)

Supported operations:

/

Delete user

Role Permissions

Role Permission
Admin Full administrative permissions
Member Standard usage permissions
Viewer Read-only permissions

Security best practices

Daily Use

Enterprise Deployment


Common questions

Q: How do I prevent Codex from deleting important files?

Use read-only or workspace-write sandbox mode, and add Rules to prohibit deletion commands.

Q: How does an enterprise configure things uniformly?

Using the managed configuration feature, enterprise administrators can distribute unified configurations that override user settings.

Q: What information is included in audit logs?

Complete records of all sessions, tool calls, model calls, and user operations.

Q: How do I handle sensitive data?

Use Secrets to store sensitive information; they are only available in setup scripts and are automatically removed during the Agent phase.