What this thread does
As of November 2026, match the permission profile to the review job and keep privilege reduction enabled.
Do first: choose :read-only for a read-only reviewer and use a disposable Linux or macOS runner with drop-sudo; Windows supports only the action's unsafe strategy. Action README.
The problem
Teams want Codex to review pull requests or triage issues from CI, but the prompt contains text written by strangers (PR titles, bodies, commit messages) and the job holds an OPENAI_API_KEY. The action's own security notes explain how that goes wrong and what to set.
What the action does
openai/codex-action (repository by OpenAI, Apache-2.0) installs the Codex CLI in the runner and starts a local proxy to the Responses API so the key is not handed to Codex itself. You provide the key as a GitHub Actions secret and a prompt (or prompt-file). The README's example is a PR review bot: check out the PR merge ref with persist-credentials: false, fetch base and head refs, run the action, then post final-message as a comment from a separate job with only the write permissions it needs.
Settings that matter (from the action's docs)
- Who can trigger it: by default only users with write access. Widen
allow-usersor the bot allow-lists only with care; withallow-users: "*"the docs warn about people burning your key quota. - Permission profile: use
permission-profile: ":read-only"for read-only review, or":workspace"when the checkout needs edits;:workspacegrants no network, so download dependencies beforehand. Profiles are beta and need Codex CLI 0.138.0+. Neither legacysandboxnorsafety-strategy: read-onlycan be combined with a profile; keepdrop-sudoor a configured unprivileged user. Action README. safety-strategy: defaultdrop-sudo; on Linux it also removes the runner's access to writable root-owned service sockets under/run, including Docker, and starts Codex withno_new_privsand reduced groups/capabilities. Use disposable runners because those changes can outlive the job. Runner requirements. The docs call dropping sudo (orunprivileged-user) essential, because on GitHub-hosted runners passwordless sudo plus read access to/proccan expose the key even with read-only files and no network.- Untrusted input: treat PR bodies (including hidden HTML comments), commit messages, screenshots and even
AGENTS.mdfiles from the PR as prompt-injection surface. - Shell injection: never put
${{ ... }}values straight into arun:script; pass them throughenv:and quote them. - Run Codex as the last step of a job and pass its output to a second job. A loosely permissioned Codex can leave processes running or edit files that later steps trust.
- Optional
output-schema/output-schema-filegive you structured JSON fromcodex exec --output-schema.
Caveats
This is the vendor's documentation, not a trial result. Start with read-only review comments, keep contents: read on the Codex job, and reference the action by a full commit SHA rather than @v1 if your policy requires it. Use protected main, CI as a gate and human merge as workflow boundaries.
Sources: openai/codex-action README, its security notes.
Sources
Started from a post by @OpenAI, packaged by the editor. Original post