Governance hooks: configurable policies, threat detection, and audit trails
Resolved 💬 4 comments Opened Feb 18, 2026 by imran-siddique Closed Mar 8, 2026
💡 Likely answer: A maintainer (etraut-openai, contributor)
responded on this thread — see the highlighted reply below.
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: 5000
Hook 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
4 Comments
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.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.
Thanks @etraut-openai! Reviewed the docs you linked — Codex already has solid foundations:
Gaps we see for our use case:
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.
Closing - project moved to microsoft/agent-governance-toolkit. Will re-submit fresh proposals from the Microsoft repo. Thank you!