{"version":21,"agent":"pinch","message":"MCP tools stay inside the folder the server started in. A tool call's folder, and each file the issue tool's attach names, must be that folder or inside it. A relative path that climbs out (..), an absolute path elsewhere, or a link that leads out is refused with a plain message, so no tool reads a file outside the project. The text flags' -file twins were never served as tool inputs, and a test now keeps it that way.\n\nAlso: abso login, box and logout outside an abso folder act on https://api.abso.dev when --server isn't given, so a fresh machine can run abso login bare. Inside a folder they still use the folder's server.","time":1791528460170,"timeIso":"2026-10-09T06:47:40.170Z","changes":3,"change":236,"files":["client/src/main.ts","client/src/mcp.ts","client/test/client.test.ts"],"draft":null,"diff":[{"path":"client/src/main.ts","added":5,"removed":4,"diff":"--- a/client/src/main.ts\n+++ b/client/src/main.ts\n@@ -37,6 +37,7 @@\n \ttakeNews,\n } from \"./commands.ts\";\n import { configPath, findRoot, installKey, readConfig, readToken } from \"./config.ts\";\n+import { TOKEN_SERVERS } from \"./core.ts\";\n import { runDraftSync, runLand, runSwitch } from \"./drafts.ts\";\n import { runExport } from \"./export.ts\";\n import { runBlame, runWhere, runWho, runWhy } from \"./history.ts\";\n@@ -56,12 +57,12 @@\n \treadonly run: (args: Parsed, env: Env) => Promise<Output>;\n }\n \n-/** The server login, box and logout act on: --server, or the folder's. */\n-function boxServer(args: Parsed, env: Env): string {\n+/** The server login, box and logout act on: --server, the folder's, or outside a folder abso.dev's (TOKEN_SERVERS[0]). */\n+export function boxServer(args: Parsed, env: Pick<Env, \"cwd\">): string {\n \tconst flag = str(args, \"server\");\n \tif (flag) return flag;\n \tconst root = findRoot(env.cwd);\n-\tif (!root) throw new UsageError(\"give --server <url>, or run this inside an agent's folder\");\n+\tif (!root) return TOKEN_SERVERS[0]!;\n \treturn (JSON.parse(readFileSync(configPath(root), \"utf8\")) as { server: string }).server;\n }\n \n@@ -166,7 +167,7 @@\n \t\tflags: { server: \"string\" },\n \t\tusage: \"abso login [--server <url>]\",\n \t\tabout:\n-\t\t\t\"Sign this box in once (abso issue 108): it shows a code and a link, and waits while a person approves the code on the website, choosing the projects, the highest role and how many agents. Then abso join in any of those projects gives each agent its own key, with no approval. The box's sign-in is kept in your user folder, never in a project folder, and is never printed. Without --server, the folder's server.\",\n+\t\t\t\"Sign this box in once (abso issue 108): it shows a code and a link, and waits while a person approves the code on the website, choosing the projects, the highest role and how many agents. Then abso join in any of those projects gives each agent its own key, with no approval. The box's sign-in is kept in your user folder, never in a project folder, and is never printed. Without --server, the folder's server, or https://api.abso.dev outside a folder.\",\n \t\trun: async (args, env) => {\n \t\t\tconst server = boxServer(args, env);\n \t\t\tconst record = await login(server, { say: (line) => process.stderr.write(`${line}\\n`) });"},{"path":"client/src/mcp.ts","added":51,"removed":3,"diff":"--- a/client/src/mcp.ts\n+++ b/client/src/mcp.ts\n@@ -9,7 +9,8 @@\n // The protocol is JSON-RPC 2.0, one message per line, with no library: the\n // client uses nothing outside Node.\n \n-import { resolve } from \"node:path\";\n+import { realpathSync } from \"node:fs\";\n+import { isAbsolute, relative, resolve, sep } from \"node:path\";\n import { clientVersion } from \"./client-version.ts\";\n import { commandTable, main } from \"./main.ts\";\n \n@@ -92,7 +93,8 @@\n \t\t\t\t\t},\n \t\t\t\t\tfolder: {\n \t\t\t\t\t\ttype: \"string\",\n-\t\t\t\t\t\tdescription: \"The abso folder to run in (default: the folder this server started in).\",\n+\t\t\t\t\t\tdescription:\n+\t\t\t\t\t\t\t\"The abso folder to run in: the folder this server started in (the default), or one inside it.\",\n \t\t\t\t\t},\n \t\t\t\t\tjson: { type: \"boolean\", description: \"Answer with the command's JSON (as --json) instead of its text.\" },\n \t\t\t\t\t...flags,\n@@ -103,6 +105,50 @@\n \t});\n }\n \n+/** A path as it really is (through links), or as given when it doesn't exist. */\n+function real(path: string): string {\n+\ttry {\n+\t\treturn realpathSync.native(path);\n+\t} catch {\n+\t\treturn path;\n+\t}\n+}\n+\n+/** Whether `path` is `start` or inside it, after links are followed. */\n+function inside(start: string, path: string): boolean {\n+\tconst rel = relative(real(start), real(path));\n+\treturn rel === \"\" || (rel !== \"..\" && !rel.startsWith(`..${sep}`) && !isAbsolute(rel));\n+}\n+\n+/**\n+ * Where a tool call runs, and what it may read (Security on 233): its folder and\n+ * every --attach file stay inside the folder the server started in. A relative\n+ * path that climbs out (..), an absolute one elsewhere, or a link out is\n+ * refused, so no tool reads a file outside the project. Answers the folder, or\n+ * why the call is refused.\n+ */\n+export function confineCall(\n+\tstart: string,\n+\tinput: Readonly<Record<string, unknown>>,\n+): { folder: string } | { refused: string } {\n+\tconst named = typeof input.folder === \"string\" && input.folder !== \"\" ? input.folder : undefined;\n+\tconst folder = named === undefined ? start : resolve(start, named);\n+\tif (!inside(start, folder))\n+\t\treturn {\n+\t\t\trefused: `folder ${JSON.stringify(named)} is outside ${start}, the folder this server started in; tools run there or below`,\n+\t\t};\n+\tif (typeof input.attach === \"string\")\n+\t\tfor (const p of input.attach\n+\t\t\t.split(\",\")\n+\t\t\t.map((x) => x.trim())\n+\t\t\t.filter((x) => x !== \"\"))\n+\t\t\tif (!inside(start, resolve(folder, p)))\n+\t\t\t\treturn {\n+\t\t\t\t\trefused: `--attach ${p} is outside ${start}, the folder this server started in; a tool attaches files from there or below`,\n+\t\t\t\t};\n+\treturn { folder };\n+}\n+\n /** The command line a tool call stands for: flags as --name=value, then the words after --. */\n export function argvFor(command: string, input: Readonly<Record<string, unknown>>): string[] {\n \tconst def = commandTable()[command]!;\n@@ -158,7 +204,9 @@\n \t\t\t\tconst command = MCP_COMMANDS.find((c) => toolName(c) === name);\n \t\t\t\tif (command === undefined) return fail(id, -32602, `no tool ${JSON.stringify(name)}; tools/list names them`);\n \t\t\t\tconst args = (params.arguments ?? {}) as Record<string, unknown>;\n-\t\t\t\tconst folder = typeof args.folder === \"string\" && args.folder !== \"\" ? resolve(cwd, args.folder) : cwd;\n+\t\t\t\tconst where = confineCall(cwd, args);\n+\t\t\t\tif (\"refused\" in where) return reply(id, { content: [{ type: \"text\", text: where.refused }], isError: true });\n+\t\t\t\tconst folder = where.folder;\n \t\t\t\tlet streamed = \"\";\n \t\t\t\tconst result = await main(argvFor(command, args), {\n \t\t\t\t\tcwd: folder,"},{"path":"client/test/client.test.ts","added":52,"removed":2,"diff":"--- a/client/test/client.test.ts\n+++ b/client/test/client.test.ts\n@@ -48,8 +48,8 @@\n import { absolute, writeFileAtomic } from \"../src/folder.ts\";\n import { runHook } from \"../src/hook.ts\";\n import { tryFolderLock } from \"../src/lock.ts\";\n-import { commandTable, main } from \"../src/main.ts\";\n-import { argvFor } from \"../src/mcp.ts\";\n+import { boxServer, commandTable, main } from \"../src/main.ts\";\n+import { argvFor, confineCall, mcpTools } from \"../src/mcp.ts\";\n import { pulledText } from \"../src/queue.ts\";\n import { noteText, titleLine } from \"../src/review.ts\";\n import { screenAnswer, throughLink, unsafeLink, unsafePath } from \"../src/safety.ts\";\n@@ -2641,6 +2641,56 @@\n \t\tassert.deepEqual(parsed.positionals, [\"--server=x\"]);\n \t});\n \n+\tit(\"keeps a tool call's folder and --attach files inside the folder the server started in (Security on 233)\", async () => {\n+\t\tconst { folders } = await project({ \"a.txt\": \"one\\n\" }, \"alice\");\n+\t\tconst start = folders.alice!;\n+\t\tconst refused = (input: Record<string, unknown>) => {\n+\t\t\tconst r = confineCall(start, input);\n+\t\t\treturn \"refused\" in r ? r.refused : \"\";\n+\t\t};\n+\t\tassert.deepEqual(confineCall(start, {}), { folder: start });\n+\t\tassert.deepEqual(confineCall(start, { folder: \"sub\" }), { folder: join(start, \"sub\") });\n+\t\tassert.deepEqual(confineCall(start, { attach: \"a.txt, sub/b.png\" }), { folder: start });\n+\t\tassert.match(refused({ folder: \"..\" }), /^folder \"\\.\\.\" is outside .*, the folder this server started in/);\n+\t\tassert.match(refused({ folder: dirname(start) }), /is outside/);\n+\t\tassert.match(refused({ folder: \"sub/../..\" }), /is outside/);\n+\t\tassert.match(refused({ attach: \"a.txt,../x.png\" }), /^--attach \\.\\.\\/x\\.png is outside/);\n+\t\tassert.match(refused({ attach: join(tmpdir(), \"x.png\") }), /is outside/);\n+\t\tassert.match(refused({ folder: \"sub\", attach: \"../../x.png\" }), /is outside/);\n+\t\tassert.deepEqual(confineCall(start, { folder: \"sub\", attach: \"../a.txt\" }), { folder: join(start, \"sub\") });\n+\t\tconst server = mcp(start);\n+\t\ttry {\n+\t\t\tconst up = await server.call(\"tools/call\", { name: \"status\", arguments: { folder: \"..\" } });\n+\t\t\tassert.equal(up.result.isError, true);\n+\t\t\tassert.match(up.result.content[0].text, /is outside/);\n+\t\t\tconst attach = await server.call(\"tools/call\", {\n+\t\t\t\tname: \"issue\",\n+\t\t\t\targuments: { args: [\"1\"], comment: \"see\", attach: \"../../secret.png\" },\n+\t\t\t});\n+\t\t\tassert.equal(attach.result.isError, true);\n+\t\t\tassert.match(attach.result.content[0].text, /^--attach \\.\\.\\/\\.\\.\\/secret\\.png is outside/);\n+\t\t} finally {\n+\t\t\tserver.close();\n+\t\t}\n+\t});\n+\n+\tit(\"serves no -file twin, so no tool reads its text from a file\", () => {\n+\t\tfor (const tool of mcpTools())\n+\t\t\tfor (const key of Object.keys(tool.inputSchema.properties as object))\n+\t\t\t\tassert.ok(!key.endsWith(\"-file\") && key !== \"file\", `${tool.name} takes ${key}`);\n+\t});\n+\n+\tit(\"abso login, box and logout outside a folder act on https://api.abso.dev\", () => {\n+\t\tconst outside = mkdtempSync(join(tmpdir(), \"abso-login-\"));\n+\t\ttry {\n+\t\t\tassert.equal(boxServer(parseArgs(\"login\", [], { server: \"string\" }), { cwd: outside }), \"https://api.abso.dev\");\n+\t\t\tconst given = parseArgs(\"login\", [\"--server\", \"https://example.test\"], { server: \"string\" });\n+\t\t\tassert.equal(boxServer(given, { cwd: outside }), \"https://example.test\");\n+\t\t} finally {\n+\t\t\trmSync(outside, { recursive: true, force: true });\n+\t\t}\n+\t});\n+\n \tit(\"publish --done takes the start note back once it is published\", async () => {\n \t\tconst { folders } = await project({ \"a.txt\": \"one\\n\" }, \"alice\");\n \t\tassert.equal((await avcs(folders.alice!, \"start\", \"Two\", \"a.txt\")).exit, 0);"}],"ci":null}