Skip to content

Separate Codex identification from flat lineage corroboration #473

Closed

Description

@philcunliffe

Deferred, non-blocking review findings for PR #467 (Codex lineage reads the durable body client_metadata, not header names Codex never sends (#464), head fed35dad15cc8923ad826a9c6b1b06070a14da6f). Neither is a production defect; both are correctly follow-up material rather than blockers. Backlink: #467

Both findings concern code and prose that exist ONLY on this unmerged branch (hasCodexTransportSignal, readCodexClientMetadata, LLP 0144's header audit table) - master still has the pre-PR isCodexExchange shape and no LLP 0144. This issue is therefore blocked on PR #467 merging first; neutral:stuck is added alongside neutral:fix for that reason, not because the findings themselves need a design decision (finding B does need one).

A. hasCodexTransportSignal's user-agent branch is client-settable, and can steer the LLP 0030 partition key

hypaware-core/plugins-workspace/codex/src/exchange-projector.js:797-804 (hasCodexTransportSignal), corroborating readCodexClientMetadata at exchange-projector.js:835-845.

A forged user-agent: codex_cli_rs/1.0 header combined with a body client_metadata: { session_id, thread_id } (no x-codex-* key) still satisfies hasCodexTransportSignal and lets the flat pair dictate conversation_id and session_id (the LLP 0030 partition key), same as any other transport-corroborated Codex request.

This is pre-existing, not introduced or worsened by #467: master's predecessor (isCodexExchange, same file, pre-PR) already treated a codex-prefixed user-agent as sufficient to enter resolveCodexContext, and at that point the header fallback (readHeader(..., 'thread-id') / 'session-id') was reachable with no further gate at all. #467 actually narrows the reachable surface: exploiting it now additionally requires the attacker to also construct a matching client_metadata body map, where master's version needed only the two header names it already trusted unconditionally per-Codex-context. So #467 is a net tightening of this residual, not a regression.

Exploiting it requires deliberate impersonation of Codex's product-name convention (codex_cli_rs/...), not an accidental field-name collision - the same distinction LLP 0144 draws for the x-codex-* body key. The three other hasCodexTransportSignal branches (chatgpt upstream, /backend-api/codex/ namespace, an x-codex-* header) require knowing Codex's specific proprietary route/header vocabulary, a higher bar than a user-agent string.

The human option the PR author already spelled out (LLP 0144 lines ~95-104, and inline at exchange-projector.js:783-804): split the predicate into "may be called Codex" (loose, current four signals) vs "may have its flat pair trusted" (drop the user-agent branch from the latter), at the cost of losing lineage for a future Codex build that emits neither an x-codex-* body key nor a compatibility header and is reached only by user-agent. Worth a deliberate decision given this is a privacy-adjacent partition key in a traffic-capture product, but not urgent: the vector requires an already-untrusted local process on the user's own machine to deliberately spoof a Codex product string, and nothing about the exposure has widened relative to what shipped on master before this PR.

B. LLP 0144's audit table overstates "no Codex version emits thread-id / session-id headers" - true for the primary turn path, false for /responses/compact and the websocket handshake, but harmless in practice

llp/0144-codex-lineage-from-body-client-metadata.decision.md:37-38 ("Three of the header names read were fictional. thread-id, session-id and parent-thread-id are not names any Codex version emits") and the audit table row at line 125 (~~thread-id~~, ~~session-id~~, ~~parent-thread-id~~ | no | nothing emits them; removed). Same claim echoed in the test comment at test/plugins/codex-exchange-projector.test.js:1225-1226 ("thread-id, session-id and parent-thread-id are names Codex never emits").

Verified against openai/codex's current main branch (upstream, not vendored in this repo): codex-rs/codex-api/src/requests/headers.rs::build_session_headers inserts headers literally named "session-id" and "thread-id" (via insert_header(&mut headers, "session-id", &id) and the "thread-id" counterpart). It is called from two real call sites in codex-rs/core/src/client.rs: ModelClient::compact_conversation_history (the /responses/compact endpoint, which the projector's isOpenAiResponsesPath matches via path.startsWith('/responses/')) and ModelClient::build_websocket_headers (the websocket handshake used for stream_responses_websocket). So the "nothing emits them" claim is false for these two paths, though confirmed true (no call site) for the primary HTTP turn-streaming path (build_responses_request / stream_responses_api), which is the path essentially all ordinary Codex traffic uses.

This causes no observed under-capture in the current code: /responses/compact requests are the CodexResponsesRequestKind::Compaction kind, which (confirmed via responses_metadata.rs) has has_turn_identity = true and so its x-codex-turn-metadata blob (sent as a header via compatibility_headers(), which compact requests do carry) independently includes session_id/thread_id - the exact fields the projector's readCodexTurnMetadata already reads. summarize_memories requests (CodexResponsesRequestKind::Memory) carry no identity on any surface at all, by Codex's own design (has_turn_identity is false for Memory), so there is nothing for either the old or the new code to read there either way. The websocket-handshake case wasn't checked further since HypAware's HTTP-proxy gateway model likely doesn't distinguish it as a normal request/response exchange; flagged here for completeness rather than as a live concern.

Net effect: purely a documentation-accuracy issue. Suggested fix: correct LLP 0144's audit table (lines 37-44, 113-125) to note session-id/thread-id are real headers on the compaction and websocket-handshake paths specifically (still correctly unread by the projector, since the turn-metadata blob already supplies the same values for the one kind where it matters), rather than claiming no Codex version emits them at all.

Activity

  1. added
    neutral:fix
    neutral:stuck
    on Jul 30, 2026
  2. philcunliffe commented on Jul 30, 2026

    @philcunliffe
    ContributorAuthor

    PR #467 is merged, so this is unblocked. Decisions:

    A: tighten. Split the predicate as the PR author sketched (LLP 0144 ~95-104): "may be called Codex" keeps all four signals, but "may have its flat pair trusted" drops the user-agent branch. Accept the cost that a hypothetical future Codex build reached only by user-agent loses lineage until we update; a spoofable string should not steer the LLP 0030 partition key.

    B: proceed. Correct LLP 0144's audit table to say session-id/thread-id are real headers on the compaction and websocket-handshake paths specifically (still correctly unread, since the turn-metadata blob supplies the same values where it matters), and fix the echoed test comment. Factual correction of a wrong claim, handle per the house immutability rules.

  3. removed
    neutral:stuck
    on Jul 30, 2026
  4. philcunliffe commented on Oct 6, 2026

    @philcunliffe
    ContributorAuthor

    The maintainer decision in the July 30 comment is already sufficient authorization; no new design question or parent-merge hold remains. Current master still passes hasCodexTransportSignal directly into readCodexClientMetadata, and the predicate still includes a Codex user-agent. Implement the approved split now: keep the loose signals for client identification/entrypoint attribution, but exclude a user-agent-only match when deciding whether an otherwise ambiguous flat session_id + thread_id map may set lineage. Preserve the existing Codex-owned body-key path and stronger route/upstream/compatibility-header corroboration, along with established metadata precedence. Never drop ordinary conversation content just because corroborated lineage is unavailable.

    This is a capture-classification tightening, not authentication of the sending process: the remaining local headers/body markers are also client-supplied. Do not describe them as a security proof, add credential validation, or reopen the approved tradeoff about a hypothetical future user-agent-only Codex build. No historical rewrite or graph identity migration is requested here.

    The referenced lineage LLP was renumbered: current code cites LLP 0151, and the source is llp/0151-codex-lineage-from-body-client-metadata.decision.md. It still contains the blanket claim that no Codex version emits thread-id/session-id headers. Carry out the previously approved factual correction with precise upstream source revision/path attribution for the compaction/handshake cases; do not replace one timeless upstream claim with another or reinstate the removed generic header fallback. Correct the mirrored test comments as well. Follow immutability rules: the new corroboration policy belongs in an extension with a forward reference; factual/editorial corrections must not silently rewrite the old policy's meaning.

    Acceptance: the real projector sees a generic Responses request with only a Codex user-agent and flat IDs and does not use those IDs as session/conversation lineage; it still identifies the client and records content. Cover an unrelated user-agent, each preserved corroborator, Codex-owned body metadata without transport hints, incomplete/invalid flat pairs and existing body/header precedence. Pin the approved loss-of-lineage fallback rather than assuming no row is produced. CPU/memory: bounded checks over the existing headers/body map, no I/O, external lookup, extra body copies or unbounded identity cache. Ready for Neutral against current master.

  5. changed the title [-]Follow-up: deferred review findings from PR #467[/-] [+]Separate Codex identification from flat lineage corroboration[/+] on Oct 6, 2026
  6. HypForge commented on Oct 16, 2026

    @HypForge
    Contributor

    Fixed by #517, merged to master as ff1f9de.

    • The Codex projector now lets an unnamespaced client_metadata session_id/thread_id pair set row identity only when a namespace signal corroborates it: the chatgpt upstream, the /backend-api/codex/ route, or an x-codex-* header. A copied codex user-agent still names the client, but its flat pair no longer sets identity.
    • LLP 0165 records the split, the header-audit correction to LLP 0151 (pinned to openai/codex rust-v0.146.0), and that this is classification, not authentication, per the decision on this issue.
    • Evidence: an acceptance test shows that a forged user-agent replay of a real turn's pair, or a malformed pair, never lands on that turn's session_id or conversation_id. It fails against the old projector. Each corroborator is also tested on its own. npm test 8203 / 8200 pass / 0 fail / 3 skipped, typecheck, gateway_codex_capture smoke, and 8 CI checks green at the merged head. The final review was clean and low risk.

    🤖 Generated with Claude Code

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

    neutral:fix

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions