Skip to content

everything: add tests that error paths carry no credential values (validation errors, gzip refusal, opt-in on or off) #5646

Done

Description

@reservoir-cmyk

The get-env masking contract is pinned on its success path (tools.test.ts), but a credential value can surface on other faces: a validation error, another tool's refusal, an error handler serializing internal state. The three cases below plant a secret under a name every reading of the masking rule treats as credential-like (OPENAI_API_KEY) and pin that the value appears in none of those error surfaces — including with GET_ENV_INCLUDE_SECRETS=1, which by the documentation opens get-env's own output only. This began as a leak probe; no leak was found, so the cases are proposed as characterization tests. All three pass against the current implementation.

Cases

  1. Validation errors carry no credential value — invalid-argument calls to get-structured-content and get-annotated-message return errors, and the full response text contains no trace of the planted value; the errors speak only about what is wrong with the arguments.
  2. The gzip tool's private-address refusal carries no credential value — a fetch to 127.0.0.1 is refused, and the refusal speaks only about the address and the remedy; the planted value does not appear.
  3. The same refusal stays clean with GET_ENV_INCLUDE_SECRETS=1 — the opt-in is documented for get-env's own disclosure ("with it set, every credential … reaches the model's context" is written about get-env's output); nothing documents it opening other tools' error paths, and it does not.

Proposed tests

Beside the get-env masking cases in src/everything/__tests__/tools.test.ts (case 1) and the refusal cases in gzip-private-addresses.test.ts (cases 2–3), or as a single file (verified as one file):

/**
 * Secret
 * leakage through ERROR paths — a probe first, a pin second. The
 * get-env masking contract is pinned on its success path
 * (tools.test.ts), but nothing pinned the error paths of OTHER
 * tools: a planted credential value (a name every reading of the
 * masking rule agrees is credential-like) must not surface in a
 * validation error, nor in the gzip tool's refusal — with the opt-in
 * flag OFF, and also with it ON: GET_ENV_INCLUDE_SECRETS opens
 * get-env's own output, not every other tool's errors. The probe
 * found no leak on any of these paths; this file pins that.
 */
import { afterEach, describe, expect, it, vi } from "vitest";
import {
  connect,
  type Session,
} from "./harness.js";

const SECRET = "planted-secret-wave2-7f3a";

let session: Session | undefined;

afterEach(async () => {
  await session?.close();
  session = undefined;
  vi.unstubAllEnvs();
});

async function open(): Promise<Session> {
  session = await connect();
  return session;
}

describe("error paths carry no credential value", () => {
  it("not in a validation error, with masking on", async () => {
    vi.stubEnv("OPENAI_API_KEY", SECRET);
    vi.stubEnv("GET_ENV_INCLUDE_SECRETS", undefined);
    const s = await open();
    const structured = await s.client.callTool({
      name: "get-structured-content",
      arguments: { location: "Paris" },
    });
    expect(structured.isError).toBe(true);
    expect(JSON.stringify(structured)).not.toContain(SECRET);
    const annotated = await s.client.callTool({
      name: "get-annotated-message",
      arguments: { messageType: "info" },
    });
    expect(annotated.isError).toBe(true);
    expect(JSON.stringify(annotated)).not.toContain(SECRET);
  });

  it("not in the gzip tool's private-address refusal, with masking on", async () => {
    vi.stubEnv("OPENAI_API_KEY", SECRET);
    vi.stubEnv("GET_ENV_INCLUDE_SECRETS", undefined);
    const s = await open();
    const result = await s.client.callTool({
      name: "gzip-file-as-resource",
      arguments: { name: "x.gz", data: "http://127.0.0.1:9/secret" },
    });
    expect(result.isError).toBe(true);
    expect(JSON.stringify(result)).not.toContain(SECRET);
  });

  it("not in the gzip tool's refusal even with GET_ENV_INCLUDE_SECRETS=1", async () => {
    vi.stubEnv("OPENAI_API_KEY", SECRET);
    vi.stubEnv("GET_ENV_INCLUDE_SECRETS", "1");
    const s = await open();
    const result = await s.client.callTool({
      name: "gzip-file-as-resource",
      arguments: { name: "x.gz", data: "http://127.0.0.1:9/secret" },
    });
    expect(result.isError).toBe(true);
    expect(JSON.stringify(result)).not.toContain(SECRET);
  });
});

Verification

Ran against a byte-identical copy of v2/main @ 6cfff62 (Node 24, vitest 4.1.12): 3 passed — the planted value appeared in none of the error surfaces, with the opt-in flag off or on. Full everything suite in the same tree: 497 passed; the single failure in that run is a separate, deliberately failing question test from another proposal, unrelated to these cases.

Prompt used

"In src/everything, pin that error paths carry no credential values. Plant a secret under a name every reading of the masking rule treats as credential-like (OPENAI_API_KEY), then: (1) invalid-argument calls to get-structured-content and get-annotated-message return validation errors containing no trace of the value; (2) gzip-file-as-resource's private-address refusal likewise; (3) the same refusal with GET_ENV_INCLUDE_SECRETS=1 still contains no trace — the opt-in opens get-env's own output, not other tools' errors. This began as a leak probe; no leak was found, so it is pinned as a characterization."

Activity

  1. Shanmukh-l33t commented on Nov 22, 2026

    @Shanmukh-l33t

    Added the three cases as one new file, as the issue allows: src/everything/__tests__/error-path-secret-hygiene.test.ts

    OPENAI_API_KEY is stubbed to a credential-like value and the whole serialized tools/call result is asserted not to contain it.

    1. Invalid arguments to get-structured-content and get-annotated-message return validation errors with no trace of the value.
    2. gzip-file-as-resource refuses 127.0.0.1 with a message about the address and the remedy, and no trace of the value.
    3. The same refusal with GET_ENV_INCLUDE_SECRETS=1 stays clean, and a control call in that session shows get-env really does return the unmasked value, so case 3 is not passing on a stubbed-out flag.

    The tests also pin that the validation errors name the tool and that the refusal says "not a public address", so the absence assertions are not vacuous. Injecting the value into the refusal message makes 2 of the 4 fail.

    Branch: test/5646-error-path-secret-hygiene on my fork
    main...Shanmukh-l33t:servers:test/5646-error-path-secret-hygiene

    Results, Node 20.19.5, vitest 4.1.12, no production code touched, so this is a characterization and there is no RED:

    • the new file alone: 4 passed
    • full src/everything suite: 28 files, 519 passed
    • unmodified main in the same tree: 27 files, 515 passed, so the 4 are exactly the new cases
    • prettier check clean, eslint at max warnings 0 clean, tsc -p tsconfig.test.json clean

    AI-assisted preparation; I reviewed the diff and ran the commands above.

  2. reservoir-cmyk commented on Nov 22, 2026

    @reservoir-cmyk
    Author

    Thank you for picking this up and implementing it! Glad to see the three cases land as a dedicated file, and that the full everything suite stays green with them included. Much appreciated.

  3. added
    chore
    server-everything
    on Nov 30, 2026
  4. cliffhall commented on Nov 30, 2026

    @cliffhall
    Member

    Triage: Priority Low (total 2)

    • Severity 1: proposed characterization tests; no defect was found
    • Urgency 1: no time pressure
    • Bonuses: none

    Board: Servers V2 (#43), Status Incoming, awaiting maintainer review (no milestone yet).

  5. added this to the v2.7.0 milestone on Nov 30, 2026
  6. self-assigned this
    on Nov 30, 2026
  7. cliffhall commented on Nov 30, 2026

    @cliffhall
    Member

    Done in #5702, merged into v2/main; ships in v2.7.0.

  8. added a commit that references this issue on Dec 5, 2026
    6fcfd18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

choreserver-everythingv2

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions