Skip to content

[Bug]: test suite sends fixture credentials to real provider hosts (43 files, 9 hosts) #8848

Closed

Description

@lidge-jun

Client or integration

Other

Area

Other

Summary

The test suite sends real network requests, mostly carrying fixture credentials, to real provider hosts. A read-only run of the full suite on dev 950b7d9 (all 3,304 test files, with an untracked logging preload that logs and never blocks) found 43 test files making 230 outbound attempts to 9 real hosts. 224 of those attempts carry a credential: bearer tokens, plus 5 OAuth refresh-grant bodies to auth.openai.com.

Every credential observed is a fixture, either a literal in the test or one built by test helpers (for example fakeChatGptJwt). None came from the developer's environment or keychain on the run host (HOME was sandboxed and no provider key variables were set). Each leak is a request getting past a mock: no test contacts a real host on purpose. The real servers answered 401 or 400, so the HTTP requests did reach them.

The problems this causes:

  • fixture tokens are sent to third-party production endpoints;
  • tests depend on network reachability and latency (test(server): keep the live-cancel pool fixture quota prime off the network #8828 was one flake from this class: a quota-prime refresh to auth.openai.com outlived a test's cleanup on a stalled runner network);
  • a future test, or a developer machine with real provider variables set, could send a real credential.

Hosts, with the number of test files reaching each: chatgpt.com (37, mostly wss), auth.openai.com (3), api.githubcopilot.com (2), api.anthropic.com, api.minimax.io, api.minimaxi.com, api.deepseek.com, opencode.ai and api.together.xyz (1 each).

Six source paths account for every leaking file:

  1. WebSocket upstream (src/server/responses/codex-ws-session.ts:55): 25 files. They mock fetch but not WebSocket.
  2. Quota probe (src/codex/quota-query-backoff.ts:137, /backend-api/wham/usage): 13 files.
  3. OpenAI refresh (src/codex/account-store.ts:1408, auth.openai.com/oauth/token): codex-account-threshold-api, chat-completions-pool-mode and native-profile-startup.
  4. Model entitlements (src/codex/model-entitlements.ts:728): management-client-config-route and native-model-toggle.
  5. src/lib/pinned-http.ts:414 uses node:https directly, so globalThis.fetch mocks never see /models: github-copilot-stream-contract, gpt61-terra-provider-rows, minimax-combo-image-input, management-provider-validation and codex-retained-root-serialization (a bun --eval child).
  6. Mocks that pass other URLs through to the real fetch: oauth-code-login (its token mock lets /api/oauth/profile through, src/oauth/anthropic-identity.ts:34) and tests/helpers/native-profile-startup-child.ts:88.

Proposed fix (owner decision 2026-11-16: investigate and propose, with no code change in this round):

  • Fix the six paths first with shared stubs, chiefly a WebSocket stub helper and a pinned-http seam that respects test transport.
  • Then add a guard in tests/preload.ts. It hooks fetch, WebSocket, net.Socket.connect (which covers TLS and node:http(s)), ClientRequest and http2.connect, and refuses a non-loopback target as a connection failure (a rejected fetch or a WebSocket error event) rather than a thrown exception.
  • Always allowed:
    • loopback (127.0.0.0/8, ::1, localhost, *.localhost, 0.0.0.0);
    • .test, .example and .invalid names, which fail at DNS and about 20 files rely on that;
    • Unix sockets and ws+unix;
    • a fetch whose proxy option points at loopback (8 files use this).
  • Allowlist of real hosts: empty. One opt-in helper (for example allowOwnInterfaceAddressesForTest()) is needed for loopback-listener-integration, which deliberately connects to the machine's own interface address.
  • Child processes: [test] preload does not reach child processes, so the guard must be passed explicitly to native-profile-startup-child.ts and the bun --eval children.

Reproduction

  1. Check out dev 950b7d9.
  2. Add an untracked preload that wraps globalThis.fetch, WebSocket, net.Socket.prototype.connect, http.ClientRequest and http2.connect. Have it log one line per attempt to a non-loopback, non-.test/.example/.invalid host: test file, method, host, path without query, and credential kind. Log header names only, never values.
  3. Run bun run test --preload <logger>. Add a temporary top-level preload in bunfig.toml so bun child processes are logged too, then revert it. Run any files cut off by the 900 s lane budget, and the serial files, in a second pass with the same logger.
  4. Group the log by test file and host.

Version

dev 950b7d9

Operating system

Linux (pen-cc-01, Ubuntu); macOS and Windows not run

Provider and model

N/A (test suite)

Logs or error output

Per-file results (credential source = where the value comes from in the test):

Test file Host(s) Credential kind Attempts Credential source
claude-integration/claude-messages-endpoint chatgpt.com bearer 2 literal
claude-integration/claude-native-affinity chatgpt.com (wss) bearer 9 literal
claude-integration/claude-native-fast-1m-ingress chatgpt.com (wss) bearer 2 literal
claude-integration/claude-outbound chatgpt.com (wss) none 2 —
codex-integration/bearer-admission-routed-provider chatgpt.com (wss) bearer 3 literal, test JWT
codex-integration/codex-account-threshold-api chatgpt.com, auth.openai.com bearer, refresh grant 4 literal
codex-integration/codex-retained-root-serialization (child) api.together.xyz bearer 2 literal
codex-integration/issue-452-empty-503 chatgpt.com (wss) bearer 1 literal
codex-integration/issue-702-expired-replay-state chatgpt.com (wss) bearer 7 fakeChatGptJwt
codex-integration/main-account-hard-lock-auth chatgpt.com bearer 1 literal
codex-integration/native-model-toggle chatgpt.com bearer 1 literal
codex-integration/native-profile-crash-boundaries (child) chatgpt.com bearer 6 literal
codex-integration/native-profile-drain-server chatgpt.com (wss) bearer 2 literal
codex-integration/native-profile-startup (child) chatgpt.com, auth.openai.com bearer, refresh grant 16 literal
oauth/oauth-code-login api.anthropic.com bearer 15 token-mock literal
providers/github-copilot/github-copilot-stream-contract api.githubcopilot.com bearer 1 literal
providers/gpt61-terra-provider-rows api.githubcopilot.com bearer 3 literal
providers/minimax-combo-image-input api.minimax.io, api.minimaxi.com bearer 2 literal
responses/agent-assertion-routes chatgpt.com bearer 1 literal
responses/chat-completions-pool-mode chatgpt.com, auth.openai.com bearer, refresh grant 4 literal
responses/chat-conversation-affinity chatgpt.com (wss) bearer 22 built in test
responses/codex-0164-request-compat chatgpt.com (wss) bearer 9 fakeChatGptJwt
responses/reasoning-retention-routing chatgpt.com (wss) bearer 6 fakeChatGptJwt
responses/reasoning-retention-v2 chatgpt.com (wss) bearer 1 literal
responses/responses-compaction-override chatgpt.com (wss) bearer 14 fakeChatGptJwt
responses/responses-inbound-store-default chatgpt.com (wss) none 3 —
responses/responses-native-main-refresh chatgpt.com (wss) bearer 1 literal
responses/responses-native-ultra-effort-wire chatgpt.com (wss) bearer 1 literal
responses/responses-opaque-blob-recovery chatgpt.com (wss) bearer 2 literal
responses/responses-retained-reasoning-stream-recovery chatgpt.com (wss) bearer 11 literal
responses/responses-self-named-namespace-scrub chatgpt.com (wss) bearer 9 literal
responses/ws-upstream chatgpt.com (wss) bearer 1 literal
routing/fastwire-response-authority chatgpt.com (wss) none 1 —
routing/subagent-fallback-handle-responses chatgpt.com bearer 9 literal
server/management-client-config-route chatgpt.com bearer 1 literal
server/management-provider-validation api.deepseek.com, opencode.ai bearer 16 literal
server/server-auth chatgpt.com (wss) bearer 12 literal
server/server-combo-failover-e2e chatgpt.com bearer 5 literal
server/server-images chatgpt.com bearer 1 fakeChatGptJwt
server/server-live chatgpt.com bearer 2 fakeChatGptJwt
server/server-live-existing-call chatgpt.com bearer 2 fakeChatGptJwt
server/server-search chatgpt.com bearer 1 literal
server/turn-state-handles chatgpt.com (wss) bearer 16 fakeChatGptJwt

Left out because they never contact a real host:

  • 58 attempts sent through a fetch proxy option pointed at 127.0.0.1;
  • loopback-listener-integration connecting to the machine's own interface address;
  • three files that only resolve names in DNS.

The logger caused no failures: 13 files that failed only in the loaded first pass passed on rerun with the logger (544 tests, 0 failures).

Screenshots and supporting files

No response

Redacted configuration

No response

Checks

  • I searched existing issues and documentation.
  • I removed secrets, tokens, account details, request credentials, and personal data.

NOT RUN: macOS and Windows (the Claude Keychain reader was not exercised). Also not covered: a host with real provider key variables set; non-Bun child processes (git, curl, codex binaries); bun children started outside the repo; Bun.fetch; and WebSocket handshake results, which were not hooked.

Activity

  1. added
    bug
    on Nov 16, 2026
  2. added
    account-pool
    streaming
    on Nov 16, 2026
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

    account-poolbugstreaming

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions