Skip to content

A desktop coding agent with free access to frontier models.

TypeScript

fix(capture): never capture settings folders, secret stores or credential files outside the project

ogsamrat3217f609ba97
diff --git a/apps/server/src/capture-context.test.ts b/apps/server/src/capture-context.test.ts
index 3cc17261..b62fa4a0 100644
--- a/apps/server/src/capture-context.test.ts
+++ b/apps/server/src/capture-context.test.ts
@@ -60,8 +60,8 @@ function write(root, files) {
const ok = (stdout, stderr = "") => ({ code: 0, stdout, stderr, truncated: false, timedOut: false });
function fakeRun(outputs, calls = []) {
- return async (file, args) => {
- calls.push({ file, args });
+ return async (file, args, options = {}) => {
+ calls.push({ file, args, env: options.env });
const output = outputs[path.basename(file)];
if (output === undefined) return null;
return typeof output === "function" ? output(args) : output;
@@ -315,6 +315,7 @@ test("#16 setup: skills/plugins with scrubbed texts, MCP servers with names only
// --- #17 package-manager config -------------------------------------------------------------
test("#17 package-manager config: keys and safe values kept, every credential key dropped, URLs stripped, scrub on top", async () => {
+ const goCalls = [];
const home = tmp("pmhome");
write(home, {
".npmrc": `registry=https://registry.npmjs.org/\n@acme:registry=https://npm.acme.dev/\n//npm.acme.dev/:_authToken=${NPM_TOKEN}\n//registry.npmjs.org/:_auth=${Buffer.from(`u:${PASSWORD}`).toString("base64")}\n_password=${PASSWORD}\[email protected]\nstrict-ssl=true\nproxy=http://proxyuser:${PASSWORD}@proxy.acme.dev:8080\n`,
@@ -332,8 +333,9 @@ test("#17 package-manager config: keys and safe values kept, every credential ke
platform: "linux",
env: {},
resolve: (command) => (command === "go" ? "/usr/local/go/bin/go" : null),
- run: fakeRun({ go: ok(JSON.stringify({ GOPROXY: `https://gouser:${PASSWORD}@goproxy.acme.dev,direct`, GOPRIVATE: "github.com/acme/*", GOFLAGS: "-mod=mod" })) }),
+ run: fakeRun({ go: ok(JSON.stringify({ GOPROXY: `https://gouser:${PASSWORD}@goproxy.acme.dev,direct`, GOPRIVATE: "github.com/acme/*", GOFLAGS: "-mod=mod" })) }, goCalls),
});
+ assert.equal(goCalls[0].env.GOTOOLCHAIN, "local", "go env never downloads a toolchain");
const byTool = Object.fromEntries(result.files.map((file) => [`${file.tool}:${file.path}`, file]));
const npm = byTool["npm:~/.npmrc"];
assert.deepEqual(npm.entries, { registry: "https://registry.npmjs.org/", "@acme:registry": "https://npm.acme.dev/", "strict-ssl": "true", proxy: "http://proxy.acme.dev:8080" });
@@ -434,7 +436,7 @@ function tracker(root, temp, extra = {}) {
const t = new outside.OutsideTracker({
root,
sessionStartMs: Date.now() - 1_000,
- privacy: privacy.currentPrivacy(),
+ privacy: extra.privacy ?? privacy.currentPrivacy(),
scrub: SCRUB,
exclusion: (abs) => (uploader.isUploadPathDenied(abs.replace(/^\/+/, "")) ? "credential" : null),
reportPath: (abs) => reported.push(abs),
@@ -679,3 +681,69 @@ test("CLI/desktop parity: the context modules match PARITY.sha256 (the same list
assert.deepEqual([...listed.keys()].sort(), files);
for (const name of files) assert.equal(createHash("sha256").update(fs.readFileSync(path.join(contextDir, name))).digest("hex"), listed.get(name), `${name} changed: port it to the CLI and update PARITY.sha256 in both`);
});
+
+// --- review fixes: settings folders, secret stores, credential files -----------------------
+
+test("credential files are never captured outside the project, wherever they are", async () => {
+ for (const file of [
+ "/h/Library/Application Support/Google/Chrome/Default/Cookies", "/h/.config/google-chrome/Default/Login Data", "/x/Web Data", "/x/Local State",
+ "/h/.mozilla/firefox/p.default/key4.db", "/x/logins.json", "/x/cookies.sqlite", "/h/Library/Keychains/login.keychain-db", "/h/.config/gh/hosts.yml",
+ "/h/.netrc", "/h/.pgpass", "/h/.npmrc", "/h/.pypirc", "/h/.aws/credentials", "/x/credentials.json", "/x/server.pem", "/x/tls.key", "/h/.ssh/id_ed25519",
+ "/h/.docker/config.json", "/h/.kube/config", "/x/dev.kubeconfig", "/h/.git-credentials", "C:\\Users\\a\\AppData\\Local\\Google\\Chrome\\User Data\\Default\\Cookies",
+ ]) assert.equal(privacy.isSecretFile(file), true, file);
+ for (const file of ["/x/index.js", "/x/config.json", "/x/README.md", "/x/keys.ts", "/x/hosts.yml", "/x/kube/deploy.yaml"]) assert.equal(privacy.isSecretFile(file), false, file);
+ const archiveOutside = await import("./session-archive/outside.js");
+ for (const file of ["/srv/app/Cookies", "/srv/app/.npmrc", "/srv/app/id_rsa", "/srv/app/cert.pem", "/srv/gh/hosts.yml"]) {
+ assert.equal(archiveOutside.outsideExclusion(file, { appDirs: [], home: "/h", includeCredentialFiles: true }), "credential", file);
+ }
+});
+
+test("a folder the agent only worked in is refused when it is a settings folder, a secret store or another account's repository", async () => {
+ const home = tmp("home-refuse");
+ const root = tmp("proj-refuse");
+ const later = { "fresh.txt": "changed this session\n" };
+ const dirs = {
+ chrome: write(path.join(home, "Library/Application Support/Google/Chrome/Default"), { Cookies: "c", "Login Data": "l", "Preferences": "{}" }),
+ config: write(path.join(home, ".config/gh"), { "hosts.yml": `oauth_token: ${GH_TOKEN}\n`, "config.yml": "git_protocol: ssh\n" }),
+ local: write(path.join(home, ".local/share/app"), later),
+ appdata: write(path.join(home, "AppData/Roaming/Code/User"), later),
+ snap: write(path.join(home, "snap/firefox/common"), later),
+ pass: write(path.join(tmp("pm"), "Bitwarden"), later),
+ };
+ const { t, reported } = tracker(root, tmp("temp-refuse"), { privacy: { home, user: null }, sessionStartMs: Date.now() - 60_000 });
+ const calls = Object.values(dirs).map((dir, i) => shellCall(`c${i}`, `cd ${JSON.stringify(dir)} && ls`, root, i));
+ calls.push({ callId: "w", tool: "bash", input: { command: "ls" }, status: "completed", start: 9, end: 10, command: "ls", cwd: path.join(home, ".config") });
+ const result = await t.processCalls(calls);
+ assert.deepEqual(result.folders, []);
+ assert.deepEqual(reported, []);
+ for (const dir of Object.values(dirs)) assert.ok((await t.refusedWorkFolder(dir)) !== null, dir);
+ // Another account's git work tree, even outside home.
+ const foreign = write(tmp("foreign"), { ".git/HEAD": "ref: refs/heads/main\n", "src/a.js": "1\n" });
+ const other = tracker(root, tmp("temp-foreign"), { uid: (process.getuid?.() ?? 0) + 1, sessionStartMs: Date.now() - 60_000 });
+ assert.equal(await other.t.refusedWorkFolder(path.join(foreign, "src")), "foreign_git");
+ const foreignResult = await other.t.processCalls([shellCall("f", `cd ${foreign}/src && ls`, root, 1)]);
+ assert.deepEqual(foreignResult.folders, []);
+ assert.deepEqual(other.reported, []);
+ // The same repository is fine for its owner.
+ const own = tracker(root, tmp("temp-own"), { sessionStartMs: Date.now() - 60_000 });
+ assert.equal(await own.t.refusedWorkFolder(path.join(foreign, "src")), null);
+});
+
+test("a folder the agent created stays allowed, even under ~/.config, minus credential files and secret stores", async () => {
+ const home = tmp("home-created");
+ const root = tmp("proj-created");
+ const made = path.join(home, ".config", "newtool");
+ const { t, reported } = tracker(root, tmp("temp-created"), { privacy: { home, user: null } });
+ write(made, {
+ "settings.json": "{}", "src/main.js": "1\n", Cookies: "c", "Login Data": "l", ".npmrc": `//r/:_authToken=${NPM_TOKEN}\n`, "id_rsa": "k", "tls.key": "k", "cert.pem": "p",
+ ".docker/config.json": "{}", "gh/hosts.yml": "x", "credentials.json": "{}", "Chrome/Default/Preferences": "{}", "1Password/data.sqlite": "x",
+ });
+ const result = await t.processCalls([shellCall("mk", `mkdir -p ${made} && cd ${made} && echo ok`, root, 1)]);
+ assert.equal(result.folders.length, 1);
+ assert.equal(result.folders[0].reason, "created");
+ assert.deepEqual(reported.map((p) => path.relative(made, p)).sort(), ["settings.json", "src/main.js"]);
+});
+
+test("Windows: a timed-out command's whole process tree is ended (taskkill /T /F)", () => {
+ assert.deepEqual(exec.windowsTreeKillArgs(4242), ["/PID", "4242", "/T", "/F"]);
+});
diff --git a/apps/server/src/context/PARITY.sha256 b/apps/server/src/context/PARITY.sha256
index 294368f3..7c4dee42 100644
--- a/apps/server/src/context/PARITY.sha256
+++ b/apps/server/src/context/PARITY.sha256
@@ -2,12 +2,12 @@
# and omnirush-gui (apps/server/src/context/). A change to one must be ported to the other and this list updated in both.
67b853751c5a32e0fc62d626837fa4be571362b26e11a6d23544db8bf8cce76c commands.ts
e13f86577014b52affc4c2336630eedcac277b974939c6741119a62b7fda439b ephemeral.ts
-af6d1f36cabedab4239e3fa2d9dc025955f708a1df2278b6a9dc463d6f2ba098 exec.ts
+5f89ff17f225ac47700d31f34c358591c8fbde794a45c156d607e5a675a2ba73 exec.ts
aa87962064344b7739fff6a5d951741b7aa96710b39fc00df6d153d19d507209 index.ts
b4460fb7279e273fbb28d42b8636d598793e4b07ff8beb7d57eb127c897136c8 network.ts
-0826cb0f15b4ac712ff0a8c0e974fe07a3527df4b2d0c55074340b4fba899f75 outside.ts
-dd4c7925b536bf48872fcad9e4659c5d39dcc0658adc517b5c44b3e5c38a6bcc pm-config.ts
-c29dffc857ae3dfb258247fbadd30deccef6a2cf2883605145d7c6983cbc2e53 privacy.ts
+809a324fdcedf0f483911cb87afca2abf6cf52261f090c500ba20a03b3c85f9a outside.ts
+d7c5638ca9204a9c51a4552e7a9b09cf7beeae9c63d9352d5950118fd5536967 pm-config.ts
+d13231905671ad40fdd73e3fe7af81e44dcc909ace606f45a79c215984b6b35d privacy.ts
d21e8ba20f64148c69d07363d23f8ab27524ed61abbfc9dfdb8634d3734f5560 processes.ts
04e135b3fdab1e8427c7279672f9896a65ff1fd8c5790d2ad3b417850a13e662 services.ts
92030e186fcd58a6acaeb9acbaac67c8003d12d0c2eb9e29113faa701885b0eb setup.ts
diff --git a/apps/server/src/context/exec.ts b/apps/server/src/context/exec.ts
index 7706d5a5..34e923d1 100644
--- a/apps/server/src/context/exec.ts
+++ b/apps/server/src/context/exec.ts
@@ -44,6 +44,11 @@ export function quietEnv(extra: NodeJS.ProcessEnv = {}): NodeJS.ProcessEnv {
}
/** Runs `file` (an absolute path) and resolves with its output, or null when it could not start. */
+/** The taskkill command line that ends a Windows process tree (tests). */
+export function windowsTreeKillArgs(pid: number): string[] {
+ return ["/PID", String(pid), "/T", "/F"];
+}
+
export const runCommand: Runner = (file, args, options = {}) => {
const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
const maxBytes = options.maxBytes ?? DEFAULT_MAX_BYTES;
@@ -87,7 +92,10 @@ export const runCommand: Runner = (file, args, options = {}) => {
let settled = false;
const kill = () => {
try {
- if (process.platform !== "win32" && typeof child.pid === "number") process.kill(-child.pid, "SIGKILL");
+ if (process.platform === "win32" && typeof child.pid === "number") {
+ // The whole tree: cmd.exe running a .cmd/.bat (npm.cmd) leaves its node child behind otherwise.
+ spawn(process.env.SystemRoot ? `${process.env.SystemRoot}\\System32\\taskkill.exe` : "taskkill", windowsTreeKillArgs(child.pid), { stdio: "ignore", windowsHide: true }).on("error", () => child.kill("SIGKILL"));
+ } else if (typeof child.pid === "number") process.kill(-child.pid, "SIGKILL");
else child.kill("SIGKILL");
} catch {
try {
diff --git a/apps/server/src/context/outside.ts b/apps/server/src/context/outside.ts
index 87f16015..b72959a7 100644
--- a/apps/server/src/context/outside.ts
+++ b/apps/server/src/context/outside.ts
@@ -16,12 +16,12 @@
// per file, 4 MiB per session) and reported to the archive too.
import { createHash } from "node:crypto";
-import { lstat, readdir, readFile, realpath } from "node:fs/promises";
+import { lstat, readdir, readFile, realpath, stat } from "node:fs/promises";
import { tmpdir } from "node:os";
-import { isAbsolute, join, relative, resolve, sep } from "node:path";
+import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
import { commandEffects, toolKind, toolPaths, type FolderVia, type ToolCall } from "./commands.js";
-import { capUtf8, isTextBuffer, tildePath, tildeText, type PrivacyContext, type Scrubber } from "./privacy.js";
+import { capUtf8, isHomeSettingsFolder, isSecretFile, isSecretFolder, isTextBuffer, tildePath, tildeText, type PrivacyContext, type Scrubber } from "./privacy.js";
export const MAX_OUTSIDE_FOLDER_TOTAL_BYTES = 200 * 1024 * 1024;
export const MAX_OUTSIDE_FOLDER_FILE_BYTES = 100 * 1024 * 1024;
@@ -107,6 +107,8 @@ export type OutsideOptions = {
/** Reports a file to the project archive (byte-exact copy under `__outside__/`). */
reportPath: (absolute: string) => void;
tempRoots?: string[];
+ /** This account's uid (tests; process.getuid() by default, none on Windows). */
+ uid?: number | null;
maxFolderBytes?: number;
maxInlineBytes?: number;
};
@@ -147,6 +149,39 @@ export class OutsideTracker {
return this.options.exclusion(path) !== null;
}
+ /**
+ * A folder the agent only worked in (did not create this session) whose
+ * files are never captured: the user's settings and app data under home
+ * (home dot-folders, ~/Library, AppData, ~/snap), browser profiles,
+ * password managers and keychains, and any folder inside a git work tree
+ * owned by another account.
+ */
+ async refusedWorkFolder(path: string): Promise<string | null> {
+ if (isHomeSettingsFolder(path, this.options.privacy.home)) return "home_settings";
+ if (isSecretFolder(path)) return "secret_store";
+ const uid = this.options.uid !== undefined ? this.options.uid : typeof process.getuid === "function" ? process.getuid() : null;
+ if (uid !== null) {
+ for (let dir = path, depth = 0; depth < 64; depth += 1) {
+ try {
+ const git = await stat(join(dir, ".git"));
+ if (git.uid !== uid) return "foreign_git";
+ break;
+ } catch {
+ // No .git here: look further up.
+ }
+ const parent = dirname(dir);
+ if (parent === dir) break;
+ dir = parent;
+ }
+ }
+ return null;
+ }
+
+ /** Whether a file outside the project may be captured: the archive's exclusions plus the credential files. */
+ private fileExcluded(path: string): boolean {
+ return isSecretFile(path) || this.options.exclusion(path) !== null;
+ }
+
/** Processes one turn's tool calls; returns the events to record. */
async processCalls(calls: ToolCall[]): Promise<{ folders: OutsideFolderEvent[]; files: OutsideFileEvent[] }> {
if (this.realRoot === null) {
@@ -230,6 +265,8 @@ export class OutsideTracker {
// Inside a folder already tracked: that one covers it.
for (const folder of this.folders.values()) if (within(folder.path, path) && (folder.created || !created)) return folder;
if (this.folders.size >= MAX_FOLDERS || this.unsafeFolder(path)) return null;
+ // Only worked in: never the user's settings, app data or secret stores (checked again at scan time).
+ if (!created && (isHomeSettingsFolder(path, this.options.privacy.home) || isSecretFolder(path))) return null;
const folder: Folder = { path, via, created, callId, reported: new Set(), bytes: 0, regenerable: 0, truncated: false };
this.folders.set(path, folder);
return folder;
@@ -247,6 +284,8 @@ export class OutsideTracker {
if (!rootStats.isDirectory()) return null;
// A folder older than the session that a command claims to create (mkdir -p on an existing one) is only "modified".
const createdNow = folder.created && (rootStats.birthtimeMs || rootStats.ctimeMs) >= this.options.sessionStartMs - 1_000;
+ // Not made this session: a work folder, which must not be a settings folder, a secret store or someone else's repository.
+ if (!createdNow && (await this.refusedWorkFolder(folder.path)) !== null) return null;
let entries = 0;
let regenerable = 0;
let added = 0;
@@ -270,6 +309,8 @@ export class OutsideTracker {
}
const path = join(dir, child.name);
if (child.isDirectory()) {
+ // Browser profiles, password managers, keychains, ~/.ssh-like folders: never, even inside a folder the agent made.
+ if (isSecretFolder(child.name)) continue;
if (SKIPPED_DIR_NAMES.has(child.name)) {
regenerable += 1;
continue;
@@ -286,7 +327,7 @@ export class OutsideTracker {
}
// Modified: written since the session started (mtime; ctime also moves on a chmod or a metadata change).
if (!createdNow && stats.mtimeMs < this.options.sessionStartMs) continue;
- if (stats.size > MAX_OUTSIDE_FOLDER_FILE_BYTES || this.options.exclusion(path) !== null) continue;
+ if (stats.size > MAX_OUTSIDE_FOLDER_FILE_BYTES || this.fileExcluded(path)) continue;
if (this.folderBytes + stats.size > limit) {
folder.truncated = true;
continue;
@@ -320,6 +361,7 @@ export class OutsideTracker {
/** One file's text for the record (once per content), reported to the archive as well. */
private async inline(path: string, kind: "temp" | "executed", callId: string | null, writer: string | null): Promise<OutsideFileEvent | null> {
+ if (isSecretFile(path)) return null;
const reason = this.options.exclusion(path);
if (reason && !(reason === "dependency" && isTempPath(path, this.temps))) return null;
let buffer: Buffer;
diff --git a/apps/server/src/context/pm-config.ts b/apps/server/src/context/pm-config.ts
index b3be253f..b855a9ec 100644
--- a/apps/server/src/context/pm-config.ts
+++ b/apps/server/src/context/pm-config.ts
@@ -9,7 +9,7 @@
import { readFile, stat } from "node:fs/promises";
import { join } from "node:path";
-import { runTool, type Runner } from "./exec.js";
+import { quietEnv, runTool, type Runner } from "./exec.js";
import { cleanText, cleanUrl, isSecretKey, tildePath, type PrivacyContext, type Scrubber } from "./privacy.js";
const MAX_CONFIG_FILE_BYTES = 256 * 1024;
@@ -260,7 +260,9 @@ export async function collectPmConfig(options: PmConfigOptions): Promise<PmConfi
}
}
const result: PmConfig = { files };
+ // GOTOOLCHAIN=local: `go env` never downloads the toolchain a go.mod or GOTOOLCHAIN asks for.
const go = await runTool("go", ["env", "-json", ...GO_ENV_KEYS], {
+ env: quietEnv({ GOTOOLCHAIN: "local" }),
timeoutMs: 5_000,
maxBytes: 64 * 1024,
...(options.run ? { run: options.run } : {}),
diff --git a/apps/server/src/context/privacy.ts b/apps/server/src/context/privacy.ts
index 8ecf46bf..90d75355 100644
--- a/apps/server/src/context/privacy.ts
+++ b/apps/server/src/context/privacy.ts
@@ -187,3 +187,61 @@ export function addressClass(address: string): AddressClass {
if (/^f[cd]/.test(ip)) return "private";
return "public";
}
+
+// --- credential files, wherever they sit ------------------------------------------------
+
+/** File names that hold credentials or browser/OS secrets (compared case-insensitively). */
+const SECRET_FILE_NAMES = new Set([
+ "cookies", "cookies-journal", "login data", "login data-journal", "login data for account", "web data", "web data-journal",
+ "local state", "key3.db", "key4.db", "logins.json", "logins-backup.json", "cookies.sqlite", "cookies.sqlite-wal", "cookies.sqlite-shm",
+ ".netrc", "_netrc", ".pgpass", "pgpass.conf", ".npmrc", ".pypirc", ".git-credentials", ".my.cnf", ".htpasswd", "kubeconfig",
+]);
+/** Path endings (portable `/`) that hold credentials. */
+const SECRET_PATH_SUFFIXES = ["gh/hosts.yml", ".docker/config.json", ".kube/config", ".config/hub", ".aws/config", ".azure/accesstokens.json", "gcloud/credentials.db", "gcloud/access_tokens.db"];
+
+/**
+ * Whether an absolute or relative path names a credential file: browser
+ * cookie and password stores, keychains, netrc/pgpass/npmrc/pypirc,
+ * `credentials*`, private keys and certificates (`*.pem`, `*.key`, `id_*`),
+ * the gh, docker and kube configs and git's credential store. Such a file
+ * is never captured outside the project, whatever folder it is in.
+ */
+export function isSecretFile(path: string): boolean {
+ const portable = path.replaceAll("\\", "/");
+ const name = (portable.split("/").at(-1) ?? "").toLowerCase();
+ if (!name) return false;
+ if (SECRET_FILE_NAMES.has(name)) return true;
+ if (name.startsWith("credentials") || name.startsWith("id_") || name.includes(".keychain")) return true;
+ if (/\.(?:pem|key|p12|pfx|jks|keystore|kdbx|gpg|asc|ovpn)$/.test(name) || name.endsWith(".kubeconfig")) return true;
+ const lower = portable.toLowerCase();
+ return SECRET_PATH_SUFFIXES.some((suffix) => lower === suffix || lower.endsWith(`/${suffix}`));
+}
+
+/** Browser profile, password-manager and keychain folders (any path component, case-insensitive). */
+const SECRET_FOLDER_COMPONENTS = [
+ /^google$/, /^chrome(?:-beta|-canary| beta| canary)?$/, /^chromium$/, /^bravesoftware$/, /^brave-browser$/, /^microsoft edge$/, /^microsoft-edge$/, /^vivaldi$/,
+ /^opera(?: software)?$/, /^mozilla$/, /^firefox$/, /^thunderbird$/, /^safari$/, /^arc$/, /^1password(?: \d+)?$/, /^bitwarden$/,
+ /^keepass(?:xc)?$/, /^lastpass$/, /^dashlane$/, /^enpass$/, /^keychains?$/, /^keyrings?$/, /^password-store$/, /^\.password-store$/,
+ /^\.gnupg$/, /^\.ssh$/, /^credentials$/, /^cookies$/,
+];
+
+export function isSecretFolder(path: string): boolean {
+ return path.replaceAll("\\", "/").split("/").some((part) => SECRET_FOLDER_COMPONENTS.some((pattern) => pattern.test(part.toLowerCase())));
+}
+
+/**
+ * Whether a folder under the home directory is the user's settings or app
+ * data rather than a work folder: any home dot-folder (`~/.config`,
+ * `~/.local`, `~/.ssh`, …), `~/Library`, `~/AppData`, `~/snap`.
+ */
+export function isHomeSettingsFolder(path: string, home: string | null): boolean {
+ if (!home) return false;
+ const portableHome = home.replaceAll("\\", "/").replace(/\/+$/, "");
+ const portable = path.replaceAll("\\", "/");
+ const windows = /^[A-Za-z]:/.test(portableHome);
+ const a = windows ? portable.toLowerCase() : portable;
+ const b = windows ? portableHome.toLowerCase() : portableHome;
+ if (!a.startsWith(`${b}/`)) return false;
+ const first = portable.slice(portableHome.length + 1).split("/")[0] ?? "";
+ return first.startsWith(".") || /^(?:library|appdata|snap|application data|local settings)$/i.test(first);
+}
diff --git a/apps/server/src/session-archive/outside.ts b/apps/server/src/session-archive/outside.ts
index 2d7121bb..bd2cad59 100644
--- a/apps/server/src/session-archive/outside.ts
+++ b/apps/server/src/session-archive/outside.ts
@@ -31,6 +31,7 @@ import {
type ScannedEntry,
} from "./manifest.js";
import type { TouchedScanResult } from "./touched.js";
+import { isSecretFile } from "../context/privacy.js";
import { REGENERABLE_DIR_NAMES } from "../session-uploader.js";
/** The regenerable folders that hold build output: a file there may be the agent's own (not a dependency or cache). */
@@ -143,6 +144,8 @@ export function outsideExclusion(absolute: string, context: { appDirs: readonly
if (context.appDirs.some((dir) => inside(dir, absolute))) return "app_state";
const rel = portablePath.replace(/^[A-Za-z]:/, "").replace(/^\/+/, "");
if (context.includeCredentialFiles !== true && isArchiveCredentialPath(rel)) return "credential";
+ // Browser cookie/password stores, keychains, netrc/npmrc/pypirc, private keys, gh/docker/kube configs (context/privacy.ts): never.
+ if (isSecretFile(portablePath)) return "credential";
if (inDependencyDir(rel)) return "dependency";
if (context.home && HOME_CACHE_DIRS.some((dir) => inside(join(context.home!, ...dir.split("/")), absolute))) return "dependency";
return null;