Repository navigation
Closed
Labels
Description
Proposal: Governance Hooks for Codex CLI
Summary
Add configurable governance hooks that allow organizations to enforce tool policies, detect threats, and generate audit trails when Codex executes code and commands.
Motivation
Codex is a powerful terminal coding agent that executes shell commands, writes files, and modifies codebases. For enterprise adoption, organizations need:
- Command policies — Allowlist/blocklist shell commands, restrict file paths, limit network access
- Threat detection — Flag data exfiltration patterns (
curl | base64, env var access, credential harvesting), privilege escalation (sudo,chmod 777), and destructive operations (rm -rf /,DROP TABLE) - Audit trails — Immutable log of every command executed, file modified, and policy decision made
- Configurable governance levels — From permissive (log only) to strict (block + require approval)
Proposed Design
A .codex/governance.yaml file in the project root:
governance:
level: moderate # permissive | moderate | strict | paranoid
commands:
allowed: ["git", "npm", "python", "node", "cat", "ls", "grep"]
blocked: ["rm -rf /", "curl * | bash", "eval"]
require_approval: ["sudo", "docker", "kubectl"]
files:
writable_paths: ["src/", "tests/", "docs/"]
protected_paths: [".env", "*.key", "*.pem", ".git/"]
network:
allowed_hosts: ["registry.npmjs.org", "pypi.org"]
block_outbound: false
audit:
enabled: true
log_path: ".codex/audit.jsonl"
include_command_output: false # For compliance
limits:
max_commands_per_session: 200
max_file_modifications: 50
max_lines_changed: 5000Hook Points
- pre-command — Before executing any shell command, validate against policy
- pre-file-write — Before modifying any file, check path restrictions
- post-command — Audit the result, check for sensitive output
- on-violation — Block execution, log violation, optionally request human approval
Use Cases
- Enterprise SOC: Security teams configure governance levels per-repo
- CI/CD Safety: Codex in CI pipelines with strict policies (no network, no secrets)
- Compliance: JSONL audit trail for SOX/SOC2 reporting
- Developer Safety: Prevent accidental destructive commands in production repos
Context
We maintain Agent-OS governance framework and have proposed similar patterns across the agent ecosystem:
- anthropics/claude-agent-sdk-python #587 — Governance hooks
- google/adk-python #4543 — GovernancePlugin
- openai/openai-agents-python — Already built trust integration
Activity
imran-siddique commentedon Feb 18, 2026
For context on production validation: The governance patterns proposed here (configurable policies, threat detection, audit trails) just got merged into github/awesome-copilot (21.6K stars) — 3 PRs accepted:
The
.codex/governance.yamlapproach proposed here follows the same pattern. Happy to contribute an implementation.etraut-openai commentedon Feb 19, 2026
Thanks for the suggestion. We already support some of this in the form of execution policy rules.
We also support monitoring and telemetry and other governance features.
Please look at these mechanisms and let us know if you see any gaps for your use case.
imran-siddique commentedon Feb 19, 2026
Thanks @etraut-openai! Reviewed the docs you linked — Codex already has solid foundations:
Gaps we see for our use case:
Argument-level threat detection — Rules can block commands, but can they inspect arguments for patterns like credential harvesting (\cat ~/.ssh/id_rsa), environment variable exfiltration (\�cho \), or encoded payloads?
Composable policies — Can teams layer policies (org → repo → session) where stricter always wins? E.g., org blocks \sudo\ globally, repo adds path restrictions, session adds rate limits.
Audit trail for compliance — Is there a structured, exportable audit log (JSONL) of all policy decisions (not just executions) for SOC2/SOX reporting?
If these are already covered and we're missing something in the docs, happy to close this. Otherwise, we can contribute implementations for any of these gaps.
imran-siddique commentedon Mar 8, 2026
Closing - project moved to microsoft/agent-governance-toolkit. Will re-submit fresh proposals from the Microsoft repo. Thank you!