Skip to content

fix(codex): pass message bodies so a leading dash is never parsed as a codex option #49

Closed

Description

@abruption

What happened

Security and stability hardening audit finding TS-01 / Medium (2026-09-28). Priority is an audit recommendation, not a claim of a production incident. This is the TypeScript counterpart of abruption/session-peer#237.

Codex delivery passes the body as a separate argv element after the option name: codex queue --thread <id> --message <text>. A body that starts with - is parsed by codex's clap parser as an option instead of text.

With codex-cli 0.157.1 and an empty temporary CODEX_HOME, the bodies --help, -x hello, -1 and - first item each failed with a clap usage error (exit 2) before any queue access, while --message=<text> parsed them and reached the expected "no rollout found" error.

A normal send is protected by the From: header prefix, but when CODEX_THREAD_ID/CODEX_SESSION_ID is absent (for example a sender that is not itself a Codex thread) or --no-from is used, the body is passed unchanged. Leading newlines are stripped by envelope(), so "\n- item" is affected too. The SSH path always sends the remote request with --no-from --no-reply-to, so the remote host hits the same argv.

Because any non-zero codex exit is mapped to CodexUnknownOutcome, a deterministic parser rejection is reported as {"error":"outcome_unknown","status":"unknown","submitted":null,"retryAllowed":false}. --dry-run returns validated for the same body because it returns before invoking codex.

What you expected

Any non-empty body, including one starting with - or --, is queued as text. Pass --message=<text> as a single argv element. A parser rejection that provably happened before queue access should not be reported as an unknown outcome.

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 an empty temporary CODEX_HOME and a nonexistent thread ID. Nothing was queued.

Source evidence

  • src/send.ts#L57 — dry-run returns before the native call
  • src/send.ts#L59-L62 — ['queue', '--thread', id, '--message', options.message]; any non-zero exit becomes CodexUnknownOutcome
  • src/protocol.ts#L29-L34 — From: prefix only when a sender UUID is present and --no-from is not set
  • src/cli.ts#L134 — SSH remote request always adds --no-from --no-reply-to

Acceptance criteria

  • Codex argv uses --message=<text> as a single element.
  • Contract tests with bodies -x, --help, - item, --, -1 and a multiline body starting with -, locally and through the SSH request path.
  • Verified against the supported codex-cli version with a temporary home.
  • Dry-run and real send agree on whether a body is accepted; existing size and NUL validation unchanged.

Scope and limitations

No shell is involved; this is option parsing, not command injection. No other codex option can be injected: every probe ended in a usage error. Unix-socket and named-pipe delivery are not affected.

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