← reports

#8008 · Codex provider emits network and shell-environment overrides

BugUrgentEffort: Mediumproviders · security · provider-codex · partial-reproIssue2026-11-22 · base 796cdcc0f4

Verdict: PARTIALLY REPRODUCED · Root-cause confidence: high for the verified BB-side request construction; the downstream administration-policy bypass is unverified.

1. TL;DR

The Codex provider explicitly requests network access on a workspace-scoped turn, even when the caller supplies no network option. The same provider copies supplied authentication-shaped environment entries into Codex shell-environment overrides, in addition to sending them to the app-server process. Both behaviors were observed at the real bridge's JSON-RPC boundary in two clean checkouts of trusted main, using non-secret synthetic values and the repository's fake Codex app-server. This is not a live exploit demonstration: the fake server does not enforce Codex administrative requirements, construct a sandboxed command environment, or execute network requests. Those downstream claims therefore remain unverified, and the overall verdict is partial.

2. Claims vs findings

ClaimStatusEvidence and limits
Workspace turns explicitly request enabled networking.VerifiedCaptured outgoing turn/start contains sandboxPolicy.networkAccess: true. The input has workspace scope and no network opt-in.
Account Pooler authentication entries are included in shell overrides.Verified at BB's output boundaryBoth authentication key names appear in the outgoing thread/start config when synthetic entries are provided. Source inspection confirms that Account Pooler contributes both names. The test does not use a real pool or a real credential.
The app-server process already receives the pool authentication entry.VerifiedThe trusted fake app-server's launch record contains the synthetic value. The production launch path merges the same provider environment into the child process.
A Codex administrative network restriction is bypassed, and real sandbox commands can export a hub credential.UnverifiedNo real Codex CLI version, administrative requirements file, sandbox command, remote model, credential, or external network endpoint was exercised. The tests establish BB's outgoing policy and configuration, not Codex's final enforcement or exfiltration.
A login-shell PATH may precede the daemon's original PATH; inherited BB-prefixed launch controls are stripped.Source-supported, partially checkedThe host-toolchain code prefers login PATH when PATH is unchanged from its inherited value, but explicitly changed caller PATH takes precedence. Existing tests for login refresh and caller overrides pass. Host plugin workers sanitize inherited BB-prefixed keys. No service-level wrapper deployment was reproduced, and the broader claim that no wrapping path exists is not established.

3. Environment

4. Minimal reproduction

The test below is investigation code written from trusted source evidence. It invokes the real bridge and records the JSON-RPC requests delivered to the repository's existing fake app-server; it does not replace the bridge or its request-building logic. Its assertions express the proposed safer invariants and are expected to fail on the recorded base. They do not establish that the current behavior violates a documented BB permission contract.

  1. Obtain a clean checkout of the trusted public repository and pin the recorded base:
    git clone https://github.com/get-bb/bb.git bb-8008-base
    cd bb-8008-base
    git checkout --detach 796cdcc0f4bf8a55e23664035c54e8db6fe9d272
    pnpm install --frozen-lockfile --prefer-offline
    pnpm exec turbo run build:types --filter=@get-bb/plugin-sdk
  2. Save the complete inline test below as plugins/provider-codex/src/bridge/issue-8008.repro.test.ts.
  3. Run the focused owner-boundary reproduction:
    pnpm exec turbo run test --filter=bb-plugin-provider-codex -- src/bridge/issue-8008.repro.test.ts

Expected safer behavior

No unconditional networkAccess:true without a caller network opt-in.
Provider authentication is not copied into shell_environment_policy.set.*.
The synthetic app-server authentication and the public control variable remain available in their intended scopes.

Actual output from both checkouts

{"observation":"workspace-turn","networkAccess":true}
{"observation":"thread-shell-overrides","credentialKeys":["shell_environment_policy.set.CODEX_POOL_AUTH_TOKEN","shell_environment_policy.set.BB_ACCOUNT_POOL_PARENT_TOKEN"],"appServerReceivedSyntheticValue":true}

AssertionError: expected true not to be true // Object.is equality
AssertionError: expected [ …(2) ] to deeply equal []
Test Files  1 failed (1)
Tests       2 failed (2)

The credential assertion examines only key names; no real credential is read or printed. The public control and synthetic process-environment assertions pass before the intended credential-isolation failure. The initial test draft had an invalid client-request ID and failed before reaching these assertions; that fixture error was corrected before either reported reproduction run.

Complete reproduction test

import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { afterEach, beforeEach, expect, it, vi } from "vitest";
import { experimental_createBridgeJsonRpcTestHarness as createBridgeJsonRpcTestHarness } from "@get-bb/plugin-sdk/provider-bridge/testing";
import { z } from "zod";
import { handleLine } from "./bridge.js";
import { stubFakeCodexAppServer } from "./fake-codex-app-server-harness.js";

const threadId = "thr_security_probe_8008";
const sessionOptions = {
  permissionMode: "accept-edits",
  permissionScope: "workspace",
  approvalReviewer: "user",
  permissionEscalation: "deny",
} as const;
const requestSchema = z.object({
  method: z.string(),
  params: z.looseObject({
    config: z.record(z.string(), z.unknown()).optional(),
    sandboxPolicy: z.looseObject({ networkAccess: z.boolean() }).optional(),
  }),
});

let harness: ReturnType<typeof createBridgeJsonRpcTestHarness>;
let workspaceDir: string;
let requestLogPath: string;
let launchLogPath: string;

beforeEach(async () => {
  workspaceDir = mkdtempSync(join(tmpdir(), "bb-security-probe-8008-"));
  requestLogPath = join(workspaceDir, "requests.jsonl");
  launchLogPath = join(workspaceDir, "launch.jsonl");
  const scriptPath = join(workspaceDir, "script.json");
  writeFileSync(scriptPath, JSON.stringify({ requestLogPath, launchLogPath }));
  vi.stubEnv("CODEX_HOME", workspaceDir);
  stubFakeCodexAppServer(scriptPath);
  harness = createBridgeJsonRpcTestHarness(handleLine);
  harness.sendRequest(1, "thread/start", {
    threadId,
    cwd: workspaceDir,
    instructionMode: "append",
    options: {
      ...sessionOptions,
      envVars: {
        CODEX_POOL_AUTH_TOKEN: "EXAMPLE-NONSECRET-8008",
        BB_ACCOUNT_POOL_PARENT_TOKEN: "EXAMPLE-NONSECRET-8008",
        REPRO_PUBLIC_VALUE: "public-control",
      },
    },
  });
  const started = await harness.waitForResponse(1);
  expect(started.error).toBeUndefined();
  const { providerThreadId } = z
    .object({ providerThreadId: z.string() })
    .parse(started.result);
  harness.sendRequest(2, "turn/start", {
    threadId,
    providerThreadId,
    clientRequestId: "creq_abcdefghjk",
    input: [{ type: "text", text: "Return a short greeting.", mentions: [] }],
    options: sessionOptions,
  });
  expect((await harness.waitForResponse(2)).error).toBeUndefined();
}, 30_000);

afterEach(async () => {
  if (harness) {
    harness.sendRequest(99, "thread/stop", {
      threadId,
      providerThreadId: "probe-cleanup",
      intent: "release",
      activeTurnId: null,
    });
    await harness.waitForResponse(99).catch(() => undefined);
    harness.restore();
  }
  vi.unstubAllEnvs();
  rmSync(workspaceDir, { recursive: true, force: true });
});

function requests() {
  return readFileSync(requestLogPath, "utf8")
    .trim()
    .split("\n")
    .map((line) => requestSchema.parse(JSON.parse(line)));
}

it("does not opt workspace turns into network access without an explicit caller request", () => {
  const turn = requests().find((request) => request.method === "turn/start");
  expect(turn).toBeDefined();
  console.log(
    JSON.stringify({
      observation: "workspace-turn",
      networkAccess: turn?.params.sandboxPolicy?.networkAccess,
    }),
  );
  expect(turn?.params.sandboxPolicy?.networkAccess).not.toBe(true);
});

it("keeps provider authentication out of shell overrides while retaining public variables", () => {
  const start = requests().find((request) => request.method === "thread/start");
  expect(start).toBeDefined();
  const config = start?.params.config ?? {};
  const launch = z
    .object({ poolToken: z.string() })
    .parse(JSON.parse(readFileSync(launchLogPath, "utf8").trim()));
  expect(launch.poolToken === "EXAMPLE-NONSECRET-8008").toBe(true);
  expect(config["shell_environment_policy.set.REPRO_PUBLIC_VALUE"]).toBe(
    "public-control",
  );
  const credentialKeys = Object.keys(config).filter(
    (key) =>
      key.endsWith(".CODEX_POOL_AUTH_TOKEN") ||
      key.endsWith(".BB_ACCOUNT_POOL_PARENT_TOKEN"),
  );
  console.log(
    JSON.stringify({
      observation: "thread-shell-overrides",
      credentialKeys,
      appServerReceivedSyntheticValue: true,
    }),
  );
  expect(credentialKeys).toEqual([]);
});

5. Root cause

Unconditional per-turn network policy

The workspace policy constructor sets networkAccess: true unconditionally. Permission translation chooses that constructor for workspace scope. Turn dispatch sends the resulting sandbox policy explicitly. No caller network preference is consulted on this path.

return {
  type: "workspaceWrite",
  writableRoots: [...writableRoots],
  networkAccess: true,
  excludeTmpdirEnvVar: false,
  excludeSlashTmp: false,
};

The generated Codex sandbox-policy union requires the boolean for workspace-write policies. Simply deleting that property is not an established compatible repair. Whether a particular Codex release constrains or rejects this explicit policy under administrator requirements needs a separate live test.

Process and command environments share one unscoped input

Config construction turns every valid provider environment entry into a dotted shell override. The common environment validator filters key syntax, not credential scope.

for (const [key, value] of Object.entries(buildShellEnvOverrides(envVars))) {
  config[`shell_environment_policy.set.${key}`] = value;
}

Account Pooler adds its parent token marker; the Codex contribution adds its authentication entry. Both carry the same host token by source inspection. The contribution path returns serving entries plus marker entries. No app-server-only classification survives into CodexSessionOptions.envVars.

The child launch separately merges those entries into the process environment. Pool launch configuration references the authentication variable through env_http_headers, without embedding its value in launch arguments. This explains why copying the authentication entry into command configuration is a separate, additional exposure path. The fake server verifies emission only; it cannot prove how real Codex applies exclusions or defaults afterward.

Related PATH note

HostToolchain.searchPath prefers shell PATH only when the supplied PATH is absent or unchanged from the inherited PATH; a caller-supplied changed PATH wins. Child environment sanitation strips inherited BB-prefixed variables, and host worker creation uses that sanitizer. This supports a narrower finding than a universal inability to wrap Codex.

6. Proposed fix and autopilot decision

First reproduce real Codex policy resolution in an isolated home and requirements environment, including a network-disabled profile, explicit per-turn policies, and version-specific enforcement. Resolve the effective restricted policy rather than silently replacing its network setting, while retaining BB's workspace and per-thread writable-root restrictions. Separate provider-process authentication from command-visible environment entries at their owning contribution and bridge boundaries; retain intentionally command-visible public values, and decide explicitly how nested BB processes obtain any required pool capability.

No automatic fix or pull request: changing network permission enforcement or where authentication material crosses a sandbox boundary changes a permission/security boundary, which is excluded by the simple-fix rule. A hard-coded token-name denylist or a network-default flip would not settle these contracts. No production patch, branch, push, or PR was made. GitHub issue timeline and open-PR search found no linked open PR at investigation time.

7. Verification

The same agent repeated the test in a second clean detached checkout at the exact base commit, after a separate frozen install and SDK types build. Only the identical authored test was then copied into that checkout. Fresh temporary workspace and Codex-home paths were created by each test; no ports or long-lived data directories were used. This was a repeat check, not independent verification.

Primary checkout: tracked production files unchanged; 2 intended assertion failures.
Second checkout: clean before copying the test; 2 identical intended assertion failures.
Reproduction source SHA-256: cd505d4e1d6955502505cdbd61159609dc4cbea9633fdd06f2a150e7f256956d
Existing Codex suites: 3 files, 85 tests passed.
Focused Account Pooler contribution test: 1 passed, 197 skipped (name-filtered existing suite).
Focused host-toolchain PATH tests: 2 passed, 16 skipped (name-filtered existing suite).
Full trusted-base build: 74 tasks successful; 9 cached. Build-generated route-tree changes were discarded; no production patch remains.

The initial full build encountered missing SDK distribution outputs. Running the SDK types task and the normal provider test's SDK build resolved that bootstrap condition before the build retry. No unrelated production changes were made. No claim was upgraded to a live requirements bypass or real credential leak after the second run.

8. Related issues

9. Appendix and boundaries

All issue text was treated as untrusted claims. No issue-provided script, command, branch, binary, external link, or proposed patch was run. The reproduction and assertions were authored from trusted repository source, and only trusted main code plus that local investigation test was executed. Raw logs and test artifacts remain local; the complete test and relevant exact output are embedded here so that the public report contains no standalone logs or environment dumps.

Validation commands

pnpm install --frozen-lockfile --prefer-offline
pnpm exec turbo run build
pnpm exec turbo run build:types --filter=@get-bb/plugin-sdk
pnpm exec oxfmt plugins/provider-codex/src/bridge/issue-8008.repro.test.ts
pnpm exec turbo run test --filter=bb-plugin-provider-codex -- src/bridge/issue-8008.repro.test.ts
pnpm exec turbo run test --filter=bb-plugin-provider-codex -- src/session-params.test.ts src/bridge/bridge.session-signature.test.ts src/bridge/app-server-launch.test.ts
pnpm exec turbo run build

Second clean checkout:
pnpm install --frozen-lockfile --prefer-offline
pnpm exec turbo run build:types --filter=@get-bb/plugin-sdk
pnpm exec turbo run test --filter=bb-plugin-provider-codex -- src/bridge/issue-8008.repro.test.ts
pnpm exec turbo run test --filter=bb-plugin-account-pool -- src/server.test.ts -t 'routes thread-less Codex model listing through the hub without recording a thread route'
pnpm exec turbo run test --filter=@bb/process-utils -- test/host-toolchain.test.ts -t 'refreshes the login PATH|keeps a caller'

No visual feature was involved; no screenshot was synthesized or required.