You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
defence-in-depth: $CODEX_HOME from env is trusted verbatim — no canonicalization or outside-$HOME check #27
resolve_codex_dir_from() (src/hooks/init.rs ~line 2773-2784) returns whatever $CODEX_HOME env var holds, without canonicalization or a "must be inside $HOME" guard. A malicious or accidentally-set env var (CODEX_HOME=/etc or CODEX_HOME=../../../tmp) would redirect init --codex / uninstall --codex writes and deletes there.
Caught by adversarial codex review of today's commit range.
Severity
Low / defence-in-depth. Same trust boundary as the binary's own process env — an attacker who can set the user's env vars already has equivalent access. The upstream OpenAI Codex CLI uses the same convention. So this is NOT a directly-exploitable vulnerability.
Filing as defence-in-depth because the binary makes destructive on-disk changes (file create/delete, file content overwrite in AGENTS.md), and adding a paranoid check is cheap.
Fix (proposed — optional)
Either:
(a) Canonicalize the resolved path (fs::canonicalize) and warn-or-bail if it escapes $HOME
(b) Just print the absolute resolved path before mutating, so an unintentional CODEX_HOME=... jumps out in interactive use
(c) Document the expectation in the help text + leave the code as-is
(c) is consistent with upstream behaviour. (a) is the strongest. (b) is the cheapest improvement.
Test plan (if fixed)
CODEX_HOME=/tmp/test-codex-home set → resolved path is used as-is (existing behaviour preserved)
CODEX_HOME=/etc triggers warning/bail (if option a)
CODEX_HOME unset → falls back to ~/.codex (existing behaviour)
Activity
Merge pull request #66 from thehoff/harden/codex-home-resolve-27
chore(release): v0.1.7 — version bump + release-engineering rebrand +…
harden(codex-home): warn when $CODEX_HOME escapes $HOME (thehoff#27)