Skip to content

feat: harden Codex runtime and automate edge updates - #14

Merged
eXPerience83 merged 27 commits into
mainfrom
agent/harden-codex-runtime-updates
Jul 25, 2026
Merged

feat: harden Codex runtime and automate edge updates#14
eXPerience83 merged 27 commits into
mainfrom
agent/harden-codex-runtime-updates

Conversation

@eXPerience83

@eXPerience83 eXPerience83 commented Jul 25, 2026

Copy link
Copy Markdown
Owner

What changed

  • Update the pinned Codex CLI from 0.144.4 to stable 0.145.0.
  • Install Ubuntu bubblewrap and report whether the outer host permits a nested Codex sandbox.
  • Tighten Codex, GitHub CLI, Git and SSH persistent-state permissions at startup and after interactive login/session actions.
  • Add tmux mouse and scrollback defaults for browser-hosted terminals.
  • Validate that Codex pins match and reject prerelease tags.
  • Check stable upstream releases daily using a reusable update branch.
  • Publish a new public edge image automatically after relevant changes merge into main.
  • Update release documentation and changelog.

Why

TrueNAS validation found three concrete issues:

  1. Codex could not start its Linux sandbox because bubblewrap was missing, so even read-only commands required approval outside the sandbox.
  2. The Apps dataset ACL caused auth.json to be created with mode 770 until corrected manually.
  3. Mouse-wheel input at plain menu prompts produced raw escape sequences.

Codex also reported stable 0.145.0 while the image remained pinned to 0.144.4.

Nested sandbox boundary

The image now contains Ubuntu's pinned bubblewrap package, but a sandbox inside Docker also depends on the outer host allowing the required user namespaces and AppArmor behavior. GitHub Actions blocks that namespace creation even though the package is correctly installed. The runtime test therefore verifies the binary, reports the compatibility result, and keeps no-new-privileges; it does not add privileged mode, SYS_ADMIN or an unconfined seccomp profile merely to force the probe green. The final behavior must be tested on the target TrueNAS host.

Update policy

The updater consumes GitHub's releases/latest endpoint and validates every external tag against an exact expected stable format before writing it. Updates open or recover a pull request; they are never merged or published silently. Build AMD64 is explicitly dispatched for the automation branch so it does not depend on approval-gated pull-request events created by GITHUB_TOKEN, and failed or cancelled validations are retried. After the required build and review pass and the PR is merged, only the public experimental edge channel is rebuilt automatically. Stable and latest project tags remain release-tag controlled.

Validation

  • Repository configuration passed (bash -n, version-pin validation and Compose validation).
  • Build AMD64 and runtime smoke tests passed on head 9fd070288e2cb1fd2d851c3048f53b426d86c012 (run chore: update stable upstream versions and runtime lock #52).
  • CodeRabbit review completed successfully and all findings are resolved.
  • Updated edge image retested on TrueNAS after merge.
  • Nested bubblewrap result recorded on TrueNAS; approval behavior verified either way.

Security

  • No privileged mode, host networking, Docker socket or host-root mount is introduced.
  • Credential directories are set to 0700; sensitive files are set to 0600 when present.
  • Every persisted non-public SSH id_* key and SSH config is hardened.
  • Upstream release values are validated before entering sourced configuration.
  • no-new-privileges remains enabled.
  • Stable image tags are not changed by this PR.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@eXPerience83, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 35 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: c03d6421-11ad-44d9-a466-840316b8a279

📥 Commits

Reviewing files that changed from the base of the PR and between 280d1dd and 58fbd9b.

📒 Files selected for processing (9)
  • .github/workflows/check-upstream.yml
  • .github/workflows/publish-edge-amd64.yml
  • CHANGELOG.md
  • docs/releases.md
  • images/base/Dockerfile
  • scripts/codex-doctor.sh
  • scripts/codex-menu.sh
  • scripts/runtime-smoke-test.sh
  • scripts/secure-persistent-state.sh

Walkthrough

The PR adds daily stable-upstream automation with synchronized Codex pins, automatic edge publishing triggers, bubblewrap installation and verification, persistent credential permission hardening, tmux configuration, and updated release documentation.

Changes

Release and runtime hardening

Layer / File(s) Summary
Stable upstream pin automation
.github/workflows/check-upstream.yml, scripts/validate-version-pins.sh, versions.env, images/codex/Dockerfile
Stable Codex tags are validated and synchronized across version declarations and the Codex Dockerfile, while upstream updates reuse a fixed branch and pull request.
Edge publishing triggers and release policy
.github/workflows/publish-edge-amd64.yml, docs/releases.md, CHANGELOG.md
Edge publishing runs on relevant pushes to main, and release documentation describes the updated stable and edge workflows.
Bubblewrap installation and verification
images/base/Dockerfile, scripts/base-verify.sh, scripts/codex-doctor.sh, scripts/runtime-smoke-test.sh, scripts/smoke-test.sh
Bubblewrap is installed and checked through dependency, version, sandbox, and no-new-privileges smoke tests.
Persistent state permissions and tmux setup
scripts/secure-persistent-state.sh, scripts/start-codex-web.sh, scripts/codex-menu.sh, images/codex/Dockerfile, images/base/Dockerfile, config/tmux.conf
Persistent credential paths receive centralized permission hardening, invoked during startup and authentication flows; tmux mouse, history, and escape-time settings are included in the base image.

Estimated code review effort: 3 (Moderate) | ~30 minutes

Sequence Diagram(s)

sequenceDiagram
  participant UpstreamWorkflow as check-upstream workflow
  participant Releases as GitHub Releases
  participant VersionPins as version pins
  participant AutomationPR as automation pull request
  participant EdgeWorkflow as publish-edge-amd64 workflow
  UpstreamWorkflow->>Releases: detect stable upstream versions
  UpstreamWorkflow->>VersionPins: synchronize versions.env and Codex Dockerfile
  UpstreamWorkflow->>AutomationPR: update or create pull request
  AutomationPR->>EdgeWorkflow: merge to main triggers edge publication
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title is concise and accurately summarizes the two main themes: Codex hardening and automated edge updates.
Description check ✅ Passed The description covers the main change, rationale, validation, and safety details, though it does not follow the template headings exactly.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/harden-codex-runtime-updates

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 280d1dd59f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .github/workflows/check-upstream.yml Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/check-upstream.yml:
- Around line 32-35: Validate latest_gh, latest_ttyd, and latest_mise against
the exact tag formats expected by their consumers before writing them to
versions.env, alongside the existing latest_codex validation. Ensure the
versions.env write path safely escapes validated values, or change both
workflows that source it to parse the file as data rather than executable shell;
do not write raw gh api output.
- Around line 40-52: Update the existing-update-PR early-exit logic around the
versions.env comparisons to also inspect the branch’s images/codex/Dockerfile
pin and compare it with the latest Codex release. Only exit when both
versions.env and the Dockerfile are current; otherwise allow the existing
validation or repair flow to run.

In `@images/base/Dockerfile`:
- Line 49: Pin the bubblewrap dependency in the Dockerfile by defining an exact
package version alongside the existing runtime version pins and installing that
version explicitly in the apt package list. Keep the current package
installation flow unchanged apart from replacing the unversioned bubblewrap
entry.

In `@scripts/secure-persistent-state.sh`:
- Around line 32-41: Update the SSH permission logic around secure_file and the
public-key loop to apply 0600 to every non-public id_* file, including ECDSA,
FIDO-backed, and other private key types, while preserving 0644 for *.pub files.
Also add conditional 0600 handling for /root/.ssh/config when present.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: e8ad6b40-2e4d-466b-908f-0b298cdc1310

📥 Commits

Reviewing files that changed from the base of the PR and between 208b69a and 280d1dd.

📒 Files selected for processing (16)
  • .github/workflows/check-upstream.yml
  • .github/workflows/publish-edge-amd64.yml
  • CHANGELOG.md
  • config/tmux.conf
  • docs/releases.md
  • images/base/Dockerfile
  • images/codex/Dockerfile
  • scripts/base-verify.sh
  • scripts/codex-doctor.sh
  • scripts/codex-menu.sh
  • scripts/runtime-smoke-test.sh
  • scripts/secure-persistent-state.sh
  • scripts/smoke-test.sh
  • scripts/start-codex-web.sh
  • scripts/validate-version-pins.sh
  • versions.env
📜 Review details
⏰ Context from checks skipped due to timeout. (1)
  • GitHub Check: build
🧰 Additional context used
📓 Path-based instructions (4)
scripts/**/*.sh

⚙️ CodeRabbit configuration file

scripts/**/*.sh: Review as production Bash. Check quoting, set -euo pipefail behavior, cleanup traps,
bounded retries and timeouts, non-interactive execution, idempotency and useful failure messages.
Flag commands that can hang, leak credentials, silently ignore failures or mutate persistent data unexpectedly.

Files:

  • scripts/smoke-test.sh
  • scripts/base-verify.sh
  • scripts/codex-menu.sh
  • scripts/validate-version-pins.sh
  • scripts/runtime-smoke-test.sh
  • scripts/secure-persistent-state.sh
  • scripts/codex-doctor.sh
  • scripts/start-codex-web.sh
.github/workflows/**

⚙️ CodeRabbit configuration file

.github/workflows/**: Review GitHub Actions for least-privilege permissions, safe event triggers, untrusted input handling,
accidental publication, tag-channel correctness, secret exposure, reproducible builds, SBOM/provenance
generation and appropriate validation before pushing images.

Files:

  • .github/workflows/publish-edge-amd64.yml
  • .github/workflows/check-upstream.yml
**/*.md

⚙️ CodeRabbit configuration file

**/*.md: Check that documentation matches the implemented behavior and clearly distinguishes experimental edge builds
from stable releases. Flag outdated versions, unsafe deployment guidance and claims not proven by CI or testing.

Files:

  • docs/releases.md
  • CHANGELOG.md
images/**/Dockerfile

⚙️ CodeRabbit configuration file

images/**/Dockerfile: Review for reproducibility, supply-chain security and minimal image growth.
Require pinned upstream versions and checksum or digest verification for downloaded binaries.
Flag secrets, floating base tags, unsafe remote-script execution, broken multi-architecture logic,
cache misuse, unnecessary packages and changes that weaken the secure-by-default runtime.

Files:

  • images/base/Dockerfile
  • images/codex/Dockerfile
🔇 Additional comments (17)
images/base/Dockerfile (1)

153-157: LGTM!

scripts/base-verify.sh (1)

4-4: LGTM!

Also applies to: 31-31

scripts/codex-doctor.sh (1)

27-47: LGTM!

Also applies to: 85-85

scripts/runtime-smoke-test.sh (1)

39-39: LGTM!

Also applies to: 48-50

scripts/smoke-test.sh (1)

19-19: LGTM!

scripts/secure-persistent-state.sh (1)

1-31: LGTM!

Also applies to: 40-42

scripts/start-codex-web.sh (1)

6-6: LGTM!

Also applies to: 20-20

scripts/codex-menu.sh (1)

21-53: LGTM!

config/tmux.conf (1)

1-5: LGTM!

scripts/validate-version-pins.sh (1)

9-9: LGTM!

Also applies to: 31-52

versions.env (1)

1-7: LGTM!

images/codex/Dockerfile (1)

6-6: LGTM!

Also applies to: 53-69

.github/workflows/check-upstream.yml (1)

5-5: LGTM!

Also applies to: 37-39, 60-66, 67-73, 74-93

.github/workflows/publish-edge-amd64.yml (2)

4-13: 🗄️ Data Integrity & Integration

Verify that automatic publication is gated by required checks.

The new push trigger starts this workflow for any matching main commit, while the supplied workflow does not check AMD64/runtime/review statuses before push: true. If branch protection is the intended gate, make those checks mandatory and block direct writes to main; otherwise add an explicit status or workflow gate.

As per path instructions, “Review GitHub Actions for … appropriate validation before pushing images.”

Source: Path instructions


74-120: LGTM!

docs/releases.md (1)

7-7: LGTM!

Also applies to: 19-20

CHANGELOG.md (1)

17-25: LGTM!

Also applies to: 34-37, 40-50

Comment thread .github/workflows/check-upstream.yml
Comment thread .github/workflows/check-upstream.yml Outdated
Comment thread images/base/Dockerfile Outdated
Comment thread scripts/secure-persistent-state.sh Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7768861edb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .github/workflows/check-upstream.yml Outdated
Comment thread .github/workflows/publish-edge-amd64.yml

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9fd070288e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/codex-menu.sh Outdated
@eXPerience83
eXPerience83 merged commit 1d24ad3 into main Jul 25, 2026
2 checks passed
@eXPerience83
eXPerience83 deleted the agent/harden-codex-runtime-updates branch July 25, 2026 14:28

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 58fbd9b231

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

chmod 700 /root/.ssh 2>/dev/null || true
chmod 600 /root/.ssh/id_ed25519 /root/.ssh/id_rsa 2>/dev/null || true
chmod 644 /root/.ssh/*.pub /root/.ssh/known_hosts 2>/dev/null || true
/usr/local/bin/secure-persistent-state

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Harden state after direct start modes exit

When a deployment uses the supported START_MODE=codex or START_MODE=shell, this hardening runs only during container startup; the tmux commands at lines 65–69 still exec Codex or Bash without invoking secure-persistent-state afterward. On hosts with the permissive dataset ACL described by this change, a token refresh or codex login from those modes can therefore leave auth.json group-readable until the whole container restarts. The fresh wrapper fix is confined to codex-menu.sh, so wrap the direct start-mode commands with the same post-session hardening.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant