Skip to content

fix(codex): keep the validated SQLite home and the codex queue database in sync (CODEX_SQLITE_HOME / sqlite_home) #50

Closed

Description

@abruption

What happened

Security and stability hardening audit finding TS-02 / Medium (2026-09-28). Priority is an audit recommendation, not a claim of a production incident.

session-peer validates the target thread and its live writer against <codexHome>/state_5.sqlite, then spawns codex queue with env: { ...process.env, CODEX_HOME: home }. codex-cli also honours CODEX_SQLITE_HOME (and the sqlite_home config key), which relocate state_5.sqlite and queue_1.sqlite. An inherited CODEX_SQLITE_HOME is passed through unchanged.

With codex-cli 0.157.1, running CODEX_HOME=<A> CODEX_SQLITE_HOME=<S> codex queue --thread <uuid> --message=probe in temporary directories created state_5.sqlite, queue_1.sqlite and the other databases under <S>, not under <A>.

Consequences:

  • When the sender environment has CODEX_SQLITE_HOME, session-peer verifies the writer of home B but codex enqueues into the database under CODEX_SQLITE_HOME, which B's TUI does not read. The result is still reported as queued.
  • When a home sets sqlite_home in config.toml, discovery and writer checks read a stale or unrelated <home>/state_5.sqlite, so sends either fail closed or are decided on outdated evidence.

The end-to-end mis-delivery with a real thread was not reproduced (it requires a live rollout); the database relocation itself was.

What you expected

The database session-peer validates is the database codex writes to. Either strip CODEX_SQLITE_HOME from the spawned environment (and refuse when it conflicts), or resolve the effective SQLite home the same way codex does and refuse unsupported configurations explicitly.

Environment

  • Baseline: published session-peer 0.2.0 (npm latest), repository commit 38a1300369443e064f58bb18e8bda70f31af0fbb.
  • Audit environment: macOS arm64, Node 22.14.0.
  • No live message tests or production mutation.
  • Reproduction: codex-cli 0.157.1 with temporary CODEX_HOME and CODEX_SQLITE_HOME directories and a nonexistent thread ID. Nothing was queued.

Source evidence

Acceptance criteria

  • The spawned codex environment cannot silently point at a different SQLite home than the validated one.
  • sqlite_home in a home's config is either resolved or reported as an explicit refusal.
  • Tests cover an inherited CODEX_SQLITE_HOME and a configured sqlite_home with temporary homes.
  • doctor reports the effective SQLite location or the unsupported configuration.

Scope and limitations

Requires a non-default codex configuration; default installs are not affected. The Python implementation in abruption/session-peer does not reference CODEX_SQLITE_HOME either, so the same gap likely exists there; this issue covers only the TypeScript port.

Checked

  • Searched existing issues in this repository and in abruption/session-peer for duplicates.
  • Removed credentials, conversation contents, private paths and real device/session identifiers.
  • Used isolated fixtures without weakening inbound permissions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions