Repository navigation
Description
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
- Validation errors carry no credential value — invalid-argument calls to
get-structured-contentandget-annotated-messagereturn errors, and the full response text contains no trace of the planted value; the errors speak only about what is wrong with the arguments. - 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.
- 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
test(everything): pin that error paths carry no credential values (mo…
Shanmukh-l33t commentedon Nov 22, 2026
Added the three cases as one new file, as the issue allows:
src/everything/__tests__/error-path-secret-hygiene.test.tsOPENAI_API_KEYis stubbed to a credential-like value and the whole serializedtools/callresult is asserted not to contain it.get-structured-contentandget-annotated-messagereturn validation errors with no trace of the value.gzip-file-as-resourcerefuses127.0.0.1with a message about the address and the remedy, and no trace of the value.GET_ENV_INCLUDE_SECRETS=1stays clean, and a control call in that session showsget-envreally 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-hygieneon my forkmain...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:
src/everythingsuite: 28 files, 519 passedtsc -p tsconfig.test.jsoncleanAI-assisted preparation; I reviewed the diff and ran the commands above.
reservoir-cmyk commentedon Nov 22, 2026
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.
cliffhall commentedon Nov 30, 2026
Triage: Priority Low (total 2)
Board: Servers V2 (#43), Status
Incoming, awaiting maintainer review (no milestone yet).cliffhall commentedon Nov 30, 2026
Done in #5702, merged into
v2/main; ships in v2.7.0.test(everything): pin that error paths carry no credential value