---
title: "Scan your repositories with Codex Security every night"
description: "Run OpenAI's Codex Security scanner every night on an exe.dev VM: code from the GitHub integration, models from the LLM integration, new findings by email."
url: https://exe-staging.dev/deploy/codex-security
category: "Security"
updated: 2026-11-16
---

# Scan your repositories with Codex Security every night

Nightly AI security scans of your repositories, with no keys on the VM.

- **Software:** Codex Security (https://learn.chatgpt.com/docs/security/cli)
- **Source:** https://github.com/openai/codex-security
- **License:** Apache-2.0
- **Time:** 10 minutes
- **Example VM name:** `my-codex-security` (yours will differ; on the VM, `hostname` prints it)
- **Machine-readable:** https://exe-staging.dev/deploy/codex-security/manifest.json
- **File:** https://exe-staging.dev/deploy/codex-security/nightly-scan.sh

## What you get

- Docker on every boot and the Codex Security 0.10.0 image pulled
- `~/security/nightly-scan.sh`, which scans the repositories in `~/security/repos.txt` through exe.dev's LLM integration, with no model key on the VM
- A systemd timer, `codex-security-scan.timer`, that runs it every night around 03:00 UTC and emails you the new findings
- A test run of the script that ends with `Nothing to scan.`

Running on the VM:

- **Codex Security**: ghcr.io/openai/codex-security:0.10.0 in Docker, data in `~/security/results`
- **Nightly scan**: nightly-scan.sh, run by the codex-security-scan systemd timer, data in `~/security/repos.txt, ~/security/scan.env`

How it is reached:

- ssh my-codex-security.exe.xyz (private): the list of repositories, settings, reports, and logs

## Deploy with Shelley

Open https://exe-staging.dev/new?prompt=Set%20up%20Codex%20Security%20on%20this%20VM%20by%20following%20the%20exe.dev%20recipe%20at%20https%3A%2F%2Fexe-staging.dev%2Fdeploy%2Fcodex-security.md%20from%20top%20to%20bottom.%0A%0AThe%20recipe%27s%20example%20VM%20name%20is%20my-codex-security.%20This%20VM%27s%20name%20is%20the%20output%20of%20%60hostname%60%3A%20use%20it%20wherever%20the%20recipe%20writes%20my-codex-security.%20Skip%20the%20step%20that%20creates%20the%20VM%3B%20you%20are%20on%20it.%0A%0AYou%20are%20done%20when%20all%20of%20these%20are%20true.%20Check%20each%20one%20yourself%3A%0A-%20Docker%20on%20every%20boot%20and%20the%20Codex%20Security%200.10.0%20image%20pulled%0A-%20%60~%2Fsecurity%2Fnightly-scan.sh%60%2C%20which%20scans%20the%20repositories%20in%20%60~%2Fsecurity%2Frepos.txt%60%20through%20exe.dev%27s%20LLM%20integration%2C%20with%20no%20model%20key%20on%20the%20VM%0A-%20A%20systemd%20timer%2C%20%60codex-security-scan.timer%60%2C%20that%20runs%20it%20every%20night%20around%2003%3A00%20UTC%20and%20emails%20you%20the%20new%20findings%0A-%20A%20test%20run%20of%20the%20script%20that%20ends%20with%20%60Nothing%20to%20scan.%60%0A%0ARun%20the%20commands%20in%20%22Install%20by%20hand%22%2C%20in%20order%2C%20and%20the%20check%20at%20its%0Aend.%20Don%27t%20add%20repositories%20to%20%60~%2Fsecurity%2Frepos.txt%60%20and%20don%27t%20start%20a%0Ascan%3A%20the%20repositories%20need%20GitHub%20integrations%2C%20which%20the%20owner%20adds%0Afrom%20their%20computer.%20Finish%20by%20telling%20the%20owner%20to%20follow%20%22Choose%20the%0Arepositories%22.%0A%0AFinish%20with%20the%20URLs%20I%20should%20open.%0A to create a VM whose agent, Shelley, follows this recipe. From a terminal:

```sh
curl -fsSL https://exe-staging.dev/deploy/codex-security/prompt.txt | ssh exe.dev new --prompt=/dev/stdin
```

Or follow the steps below by hand.

[Codex Security](https://github.com/openai/codex-security) is OpenAI's
AI security scanner. It reads a repository the way an application
security engineer would: it writes a threat model, follows data from
inputs to dangerous calls, and checks each candidate finding before it
reports it with a severity, the code path, and a suggested fix. It's
Apache-2.0 licensed; version 0.10.0 came out on November 12, 2026.

This page runs it every night on an exe.dev VM, over the repositories you
list. It scans only repositories with new commits and emails you only
findings it hasn't reported before. The model comes from exe.dev's
[LLM integration](/docs/integrations-llm) and the code from the
[GitHub integration](/docs/integrations-github), so neither a model key
nor a GitHub token is on the VM.

## Install

On exe.dev, click **Deploy** to have Shelley set it up on a new VM. Or
create it yourself:

<details class="dp-details" id="create-the-vm" data-manual-setup>
<summary>Install by hand</summary>

On your computer:

```bash
ssh exe.dev new --name=my-codex-security
ssh my-codex-security.exe.xyz
```

### Get Codex Security

On the VM, start Docker, now and on every boot, and fetch OpenAI's
Compose file and seccomp profile for the container, at the release this
page was tested with:

```bash
sudo systemctl enable --now docker.service
mkdir -p ~/security && cd ~/security
base=https://raw.githubusercontent.com/openai/codex-security/npm-v0.10.0
curl -fsSLO $base/compose.yaml
curl -fsSL --create-dirs -o docker/codex-security-seccomp.json $base/docker/codex-security-seccomp.json
mkdir -p results state && chmod 700 results state
CODEX_SECURITY_IMAGE=ghcr.io/openai/codex-security:0.10.0 docker compose pull codex-security
```

The last line pulls the 1.4 GB image. The container runs as your user,
with every Linux capability dropped and the seccomp profile applied.

### Connect it to the LLM integration

On the VM, give Codex, inside the container, a profile that sends its
requests to exe.dev's LLM integration:

```bash
cat > ~/security/state/review.config.toml <<'EOF'
model_provider = "exe-llm"

[model_providers.exe-llm]
name = "exe.dev LLM integration"
base_url = "https://llm.int.exe.xyz/v1"
wire_api = "responses"
env_key = "EXE_LLM_KEY"
EOF
```

The script sets `EXE_LLM_KEY` to a placeholder; the integration adds the
real credentials at exe.dev's edge.

### Install the nightly script

On the VM, download
[nightly-scan.sh](https://exe-staging.dev/deploy/codex-security/nightly-scan.sh)
and start an empty list of repositories:

```bash
cd ~/security
curl -fsSLO https://exe-staging.dev/deploy/codex-security/nightly-scan.sh
chmod 755 nightly-scan.sh
printf '# One GitHub repository per line, as owner/repo\n' > repos.txt
```

For each repository in `repos.txt`, the script asks GitHub for the
latest commit on the default branch and skips the repository if that
commit was already scanned. It hands the rest to Codex Security's
`bulk-scan` in the container, writes everything under
`~/security/results/runs/<time>/`, and emails you a summary that lists
only findings no earlier night has reported. Its settings are at the top:

| Setting | Default | |
| --- | --- | --- |
| `MODEL` | `gpt-5.6-terra` | any OpenAI model the [LLM integration](/llm-gateway-models) serves |
| `EFFORT` | `medium` | `low`, `medium`, `high` or `xhigh` |
| `MAX_COST` | `5` | estimated USD limit per repository |
| `MAX_TOTAL_COST` | `20` | estimated USD limit per night |
| `WORKERS` | `2` | repositories scanned at once |
| `EMAIL` | `yes` | email the owner a summary |

To change one, add it to `~/security/scan.env`, for example
`echo EFFORT=high >> ~/security/scan.env`, rather than editing the
script.

### Run it every night

On the VM:

```bash
sudo tee /etc/systemd/system/codex-security-scan.service >/dev/null <<EOF
[Unit]
Description=Nightly Codex Security scan
Wants=network-online.target
After=network-online.target docker.service

[Service]
Type=oneshot
User=$USER
ExecStart=$HOME/security/nightly-scan.sh
TimeoutStartSec=8h
EOF
sudo tee /etc/systemd/system/codex-security-scan.timer >/dev/null <<'EOF'
[Unit]
Description=Run the Codex Security scan every night

[Timer]
OnCalendar=*-*-* 03:00:00 UTC
RandomizedDelaySec=30m
Persistent=true

[Install]
WantedBy=timers.target
EOF
sudo systemctl daemon-reload
sudo systemctl enable --now codex-security-scan.timer
```

### Check the setup

On the VM:

```bash
systemctl list-timers codex-security-scan.timer --no-pager
sudo systemctl start codex-security-scan.service
journalctl -u codex-security-scan.service -n 5 --no-pager -o cat
```

The timer shows its next run, and with no repositories yet the scan ends
with `Nothing to scan.`

</details>

## Choose the repositories

The scanner reads your repositories through exe.dev's
[GitHub integration](/docs/integrations-github), which holds the GitHub
credentials at exe.dev's edge. Link your GitHub account once on the
[Integrations page](/integrations), then, on your computer, add a
read-only integration for each repository and attach it to the VM:

```bash
ssh exe.dev integrations add github --name=scan-api --repository=you/api --readonly --attach vm:my-codex-security
ssh exe.dev integrations add github --name=scan-web --repository=you/web --readonly --attach vm:my-codex-security
```

On the VM, add the same repositories to the list, and check that each
answers with a commit:

```bash
cd ~/security
echo you/api >> repos.txt
echo you/web >> repos.txt
git ls-remote https://github.int.exe.xyz/you/api.git HEAD
```

Then run the first scan now rather than waiting for the night, and
follow it:

```bash
sudo systemctl start --no-block codex-security-scan.service
journalctl -u codex-security-scan.service -f -o cat
```

A scan prints `started` and `completed` for each repository, then a
summary like this one, which also arrives by email:

```
Codex Security run 2026-11-15T0242: 2 repositories, about $0.81, 1 new findings.

pallets/itsdangerous: completed ($0.34)
pallets/markupsafe: completed ($0.46)

New findings:
[medium] pallets/markupsafe src/markupsafe/_speedups.c:83
    A large attacker-controlled string can overflow the C escape output allocation
    /home/exedev/security/results/runs/2026-11-15T0242/artifacts/pallets__markupsafe/attempt-1/report.md
```

A small library takes 1 to 3 minutes; a large application can take an
hour. Ctrl-C stops following, not the scan.

## Read the results

Each night's run has its own directory, `~/security/results/runs/<time>/`:

- `summary.txt`, the summary from the email.
- `results.jsonl`, one line per repository with its status, revision,
  and estimated cost.
- `artifacts/<owner>__<repo>/attempt-1/report.md`, the report: each
  finding with its severity, the code path from input to sink, why it
  matters, and a suggested fix.
- `findings.json` next to it, the same findings as data, with locations,
  CWE numbers and fingerprints.
- `threatmodel.md`, what Codex Security decided the repository's attack
  surface is. Worth reading once; a wrong threat model explains odd
  findings.

To read a report from your computer:

```bash
ssh my-codex-security.exe.xyz cat security/results/runs/2026-11-15T0242/artifacts/you__api/attempt-1/report.md
```

The script remembers each finding's fingerprint in
`~/security/results/seen-findings.txt` and reports a finding once. Delete
that file to hear about everything again.

## Use your own account

The LLM integration bills model use to your exe.dev account. To use an
OpenAI API key instead, keep the key off the VM with an
[HTTP proxy integration](/docs/integrations-http-proxy) for
`https://api.openai.com`, and change `base_url` in
`~/security/state/review.config.toml` to the integration's address.
[Agent secrets](/deploy/agent-secrets) explains the pattern.

Codex Security can also sign in with ChatGPT and use your plan's Codex
allowance. That suits scans you start by hand; a sign-in on a server can
expire, though, and a nightly job won't tell you until it fails.

## What it costs

The VM is an ordinary exe.dev VM on your plan. The model is billed per
token through the LLM integration. What we measured with `gpt-5.6-terra`
at medium effort:

| Repository | Time | Cost |
| --- | --- | --- |
| A 20-line Flask app with two injections | 1.5 to 2 minutes | $0.27 to $0.44 |
| itsdangerous (1,200 lines of Python) | 1.5 minutes | $0.34 |
| markupsafe (Python and C) | 3 minutes | $0.46 |

Cost grows with the repository and with effort: Codex Security's own
default, `gpt-5.6-sol` at `xhigh`, looks harder and costs several times
as much. The script's limits stop a repository at about $5 and a night at
about $20; requests in flight can go a little over. A night with no new
commits costs nothing.

## Back up and restore

On your computer:

```bash
ssh my-codex-security.exe.xyz 'tar -czf - security/repos.txt security/scan.env security/results/runs security/results/seen-findings.txt security/results/last-scanned 2>/dev/null' > codex-security-results.tgz
```

Restore by unpacking it into the home directory of a VM set up with this
page: `ssh my-codex-security.exe.xyz tar -xzf - < codex-security-results.tgz`.

## Update

The image is pinned to the version this page was tested with. To move to
a newer release, check its
[release notes](https://github.com/openai/codex-security/releases), then
name the image in `scan.env` and pull it:

```bash
cd ~/security
echo CODEX_SECURITY_IMAGE=ghcr.io/openai/codex-security:0.11.0 >> scan.env
CODEX_SECURITY_IMAGE=ghcr.io/openai/codex-security:0.11.0 docker compose pull codex-security
```

## Clean up

On your computer:

```bash
ssh exe.dev rm my-codex-security
ssh exe.dev integrations remove scan-api
ssh exe.dev integrations remove scan-web
```

## Troubleshooting

- **`can't read https://github.int.exe.xyz/...`** in the log: the
  repository has no GitHub integration attached to this VM. Check with
  `curl -s https://reflection.int.exe.xyz/integrations`, and add it as in
  [Choose the repositories](#choose-the-repositories).
- **A repository's status is `failed`**: `journalctl -u codex-security-scan -n 100`
  shows why, and the attempt's directory under `artifacts/` has the
  logs. The script remembers only completed scans, so the next run tries
  that repository again.
- **A large repository stops at its cost limit**: raise `MAX_COST` in
  `scan.env`, or scan part of it; Codex Security's
  [bulk scan docs](https://github.com/openai/codex-security/blob/main/sdk/typescript/docs/cli.md#bulk-scans)
  describe per-repository scopes.
- **No email**: the summary is in `summary.txt` either way. The
  [email gateway](/docs/send-email) only sends to you, and is
  rate-limited.
- **The timer didn't run**: `systemctl list-timers codex-security-scan.timer`
  shows the last and next run; a VM that was stopped at 03:00 runs the
  missed scan when it starts.

## Frequently asked questions

### How much does a scan cost?

The VM is part of your exe.dev plan; the model is the cost, billed to your exe.dev account through the [LLM integration](/docs/integrations-llm). In our tests, with `gpt-5.6-terra` at medium effort, small libraries cost $0.34 to $0.46 a scan and took 1.5 to 3 minutes. Large applications cost more, which is why the script stops a repository at about $5 and a night at about $20, and skips repositories with no new commits. See [What it costs](#what-it-costs).

### Can I use my ChatGPT subscription instead?

Codex Security can sign in with ChatGPT and count scans against your plan's Codex allowance, but for a scan that runs unattended every night an API key or the LLM integration is the better fit. See [Use your own account](#use-your-own-account).

### How is it different from CodeQL or Semgrep?

Those match rules against code. Codex Security has a model read the repository: it writes a threat model, follows data from an input to a dangerous call, and checks each candidate before reporting it, so it finds logic and authorization problems that rules miss, at a price per scan. They work well together.

### Does it change my code or open pull requests?

Not in this setup. The GitHub integrations are read-only, and the script only writes reports on the VM. Codex Security can draft patches, but that's a separate command this page doesn't use.

### Can it scan code I don't trust?

Use a sealed VM for that, not this one, which can read your repositories. The [Open Code Review](/deploy/open-code-review) page sets up a review box you copy for each review, cut off from the internet; installing the Codex Security CLI there works the same way.


## Related

- [Review code you don't trust with Open Code Review on a sealed VM](https://exe-staging.dev/deploy/open-code-review.md): An AI code reviewer in a box you copy, seal, and throw away.
- [Self-host PR-Agent, the AI pull request reviewer, on exe.dev](https://exe-staging.dev/deploy/pr-agent.md): Your own AI pull request reviewer, with no model key on the VM.
- [Run the Shannon AI pentester on a disposable VM](https://exe-staging.dev/deploy/shannon.md): An AI pentester for your own web apps, in a VM you delete afterwards.
- [Run Codex on a remote server](https://exe-staging.dev/deploy/codex.md): A computer for Codex. An early night for your laptop.
- [Give agents API access without giving them the keys](https://exe-staging.dev/deploy/agent-secrets.md): Your agents call your APIs. The keys stay with exe.dev, outside the VM.
- [Self-host n8n](https://exe-staging.dev/deploy/n8n-2.md): Connect your apps. Let the boring bits run themselves.
