Repository navigation
Description
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 underCODEX_SQLITE_HOME, which B's TUI does not read. The result is still reported asqueued. - When a home sets
sqlite_homeinconfig.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 commit38a1300369443e064f58bb18e8bda70f31af0fbb. - Audit environment: macOS arm64, Node 22.14.0.
- No live message tests or production mutation.
- Reproduction: codex-cli 0.157.1 with temporary
CODEX_HOMEandCODEX_SQLITE_HOMEdirectories and a nonexistent thread ID. Nothing was queued.
Source evidence
- src/send.ts#L59-L60 — spawn inherits
process.env, onlyCODEX_HOMEis overridden - src/discovery.ts#L118 — state DB fixed at
join(home, 'state_5.sqlite') - src/writer.ts#L122-L161 — writer and database fingerprinting against the same fixed path
Acceptance criteria
- The spawned codex environment cannot silently point at a different SQLite home than the validated one.
-
sqlite_homein a home's config is either resolved or reported as an explicit refusal. - Tests cover an inherited
CODEX_SQLITE_HOMEand a configuredsqlite_homewith temporary homes. -
doctorreports 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.
Activity
fix: harden Codex delivery, CLI parsing, SSH and output (#49-#57) (#62)