Skip to content

fix(guard): accept per-connection session-id UUIDs in the cache relay (Codex 0.157+ WebSocket probes) - #22

Merged
xqy2006 merged 1 commit into
xqy2006:mainfrom
QuantumMisaka:fix/guard-ws-session-id
Sep 27, 2026
Merged

xqy2006 merged 1 commit into
xqy2006:mainfrom
QuantumMisaka:fix/guard-ws-session-id

Conversation

@QuantumMisaka

Copy link
Copy Markdown
Contributor

Problem

On Codex CLI 0.157.1, guard probes always fail (fork_probe_failed, stage=inference). The 0.157 client uses the WebSocket responses transport and sends an independent per-connection UUID in the session-id header, so the cache relay's [thread-id, sessionId].includes(session-id) validation rejects every handshake; the socket is destroyed and the client reports "Handshake not finished". Full logs, evidence and environment are in #21.

Changes

  • scripts/cache-transport.mjs: accept any UUID in the incoming session-id header. The request is still authorized by allowed.has(thread-id) plus the authorization header, and the upstream leg rewrites session-id to the source cache session regardless of the incoming value.
  • tests/cache-transport.test.mjs:
    • the denial matrix now covers a non-UUID session-id (instead of a random UUID),
    • new test: a per-connection UUID is accepted and the forwarded request still carries the source cache session-id and the disposable thread-id.

Verification

  • node --test tests/*.test.mjs → 171/171 pass on this branch.
  • End-to-end on a live Codex 0.157.1 session with this change applied to 0.1.7: doctor --fork true → ready: true; probes complete (status=compatible, accepted samples with expected == reported, aggregate counts 327/327 and 293/293, countMatched: true); fork snapshot and cleanup normal.

Fixes #21.

Codex 0.157+ sends its own per-connection UUID in the session-id header for
WebSocket responses requests, which the relay's [thread-id, sessionId] check
rejects; every probe handshake is destroyed and the client reports
"Handshake not finished". Authorization stays anchored on the authorized
disposable thread id (and the upstream leg rewrites session-id anyway).

Tests: a per-connection UUID is now accepted and still rewritten upstream;
non-UUID session-id values remain rejected.
@xqy2006

xqy2006 commented Sep 27, 2026

Copy link
Copy Markdown
Owner

Thanks for the contribution.

@xqy2006
xqy2006 merged commit 54079cd into xqy2006:main Sep 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Guard: probes fail on Codex 0.157.1 (cache relay rejects WebSocket handshake because session-id is now a per-connection UUID)

2 participants