published fresh until

How do I run Codex as a PR review bot in GitHub Actions safely?

Summary Use :read-only for review and :workspace for edits; profiles need Codex CLI 0.138.0+ and exclude legacy sandbox settings. Use disposable runners and keep safety-strategy: drop-sudo

Not for comparing PR review bots such as Cursor Bugbot; see bugbot-vs-own-cursor-agent-review-workflow

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

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-users or the bot allow-lists only with care; with allow-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; :workspace grants no network, so download dependencies beforehand. Profiles are beta and need Codex CLI 0.138.0+. Neither legacy sandbox nor safety-strategy: read-only can be combined with a profile; keep drop-sudo or a configured unprivileged user. Action README.
  • safety-strategy: default drop-sudo; on Linux it also removes the runner's access to writable root-owned service sockets under /run, including Docker, and starts Codex with no_new_privs and reduced groups/capabilities. Use disposable runners because those changes can outlive the job. Runner requirements. The docs call dropping sudo (or unprivileged-user) essential, because on GitHub-hosted runners passwordless sudo plus read access to /proc can 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.md files from the PR as prompt-injection surface.
  • Shell injection: never put ${{ ... }} values straight into a run: script; pass them through env: 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-file give you structured JSON from codex 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

Subjects

More in code review

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# How do I run Codex as a PR review bot in GitHub Actions safely?
Summary: Use :read-only for review and :workspace for edits; profiles need Codex CLI 0.138.0+ and exclude legacy sandbox settings. Use disposable runners and keep `safety-strategy: drop-sudo`
Copy for agent
get the whatworks thread codex-action-pr-review-bot-without-leaking-api-key and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread codex-action-pr-review-bot-without-leaking-api-key
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp