Files
codex/.devcontainer
viyatb-oai 2fe4e06cc2 Document secure devcontainer DNS exfiltration risk (#39283)
## Why

The secure devcontainer's firewall does not apply its domain allowlist to DNS
traffic, so it does not provide secure DNS resolution for untrusted code.

## What changed

Document the DNS exfiltration risk, limit the devcontainer recommendation to
trusted repositories, and describe filtering DNS through a restricted resolver
as a partial mitigation. Clarify that allowlisted HTTPS destinations remain a
possible exfiltration path.

GitOrigin-RevId: 73cc7d29f8de17013c01411f8c20b8b5e1199b24
2026-08-18 21:18:48 +00:00
..

Containerized Development

We provide two container paths:

  • devcontainer.json keeps the existing Codex contributor setup for working on this repository.
  • devcontainer.secure.json adds a customer-oriented profile with stricter outbound network controls.

Codex contributor profile

Use devcontainer.json when you are developing Codex itself. This is the same lightweight arm64 container that already exists in the repo.

Secure customer profile

Use devcontainer.secure.json when you want a stricter runtime profile for running Codex inside a project container:

  • installs the Codex CLI plus common build tools
  • installs bubblewrap in setuid mode for Codex's Linux sandbox
  • disables Docker's outer seccomp and AppArmor profiles so bubblewrap can construct Codex's inner sandbox
  • enables firewall startup with an allowlist-driven outbound policy
  • blocks IPv6 by default so the allowlist cannot be bypassed over AAAA routes
  • requires NET_ADMIN and NET_RAW so the firewall can be installed at startup

This profile keeps the stricter networking isolated to the customer path instead of changing the default Codex contributor container.

The firewall does not apply its domain allowlist to DNS traffic, so code from an untrusted repository can exfiltrate data through DNS. This devcontainer does not provide secure DNS resolution. Use it only with trusted repositories. To mitigate DNS exfiltration, implement your own DNS filtering and restrict outbound DNS traffic to the filtered resolver; this does not make untrusted repositories safe because they can still exfiltrate data through allowed HTTPS destinations.

Start it from the CLI with:

devcontainer up --workspace-folder . --config .devcontainer/devcontainer.secure.json

In VS Code, choose Dev Containers: Open Folder in Container... and select .devcontainer/devcontainer.secure.json.

Docker

To build the contributor image locally for x64 and then run it with the repo mounted under /workspace:

CODEX_DOCKER_IMAGE_NAME=codex-linux-dev
docker build --platform=linux/amd64 -t "$CODEX_DOCKER_IMAGE_NAME" ./.devcontainer
docker run --platform=linux/amd64 --rm -it -e CARGO_TARGET_DIR=/workspace/codex-rs/target-amd64 -v "$PWD":/workspace -w /workspace/codex-rs "$CODEX_DOCKER_IMAGE_NAME"

Note that /workspace/target will contain the binaries built for your host platform, so we include -e CARGO_TARGET_DIR=/workspace/codex-rs/target-amd64 in the docker run command so that the binaries built inside your container are written to a separate directory.

For arm64, specify --platform=linux/arm64 instead for both docker build and docker run.

Currently, the contributor Dockerfile works for both x64 and arm64 Linux, though you need to run rustup target add x86_64-unknown-linux-musl yourself to install the musl toolchain for x64.

The secure profile's capability, seccomp, and AppArmor options are required when you want Codex's bubblewrap sandbox to run inside Docker as the non-root devcontainer user. Without them, Docker's default runtime profile can block bubblewrap's namespace setup before Codex's own seccomp filter is installed. This keeps the Docker relaxation explicit in the profile that is meant to run Codex inside a project container, while the default contributor profile stays lightweight.