Skip to content

abso-core

Public

abso is version control for agents: the client, the engine and a server you can run on your own Cloudflare account.

Check passed
MCP
show on this site's /mcp
CLI
abso show 21 --json
JSON
/christopher/abso-core/versions/21?format=json

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.

of shared·pinch··Not checked

Also: 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.

Version 20 · Files at version 21

3 files, 108 lines added, 9 removed.

--- a/client/src/main.ts
+++ b/client/src/main.ts
@@ -37,6 +37,7 @@
3737 takeNews,
3838} from "./commands.ts";
3939import { configPath, findRoot, installKey, readConfig, readToken } from "./config.ts";
40+import { TOKEN_SERVERS } from "./core.ts";
4041import { runDraftSync, runLand, runSwitch } from "./drafts.ts";
4142import { runExport } from "./export.ts";
4243import { runBlame, runWhere, runWho, runWhy } from "./history.ts";
@@ -56,12 +57,12 @@
5657 readonly run: (args: Parsed, env: Env) => Promise<Output>;
5758}
5859
59−/** The server login, box and logout act on: --server, or the folder's. */
60−function boxServer(args: Parsed, env: Env): string {
60+/** The server login, box and logout act on: --server, the folder's, or outside a folder abso.dev's (TOKEN_SERVERS[0]). */
61+export function boxServer(args: Parsed, env: Pick<Env, "cwd">): string {
6162 const flag = str(args, "server");
6263 if (flag) return flag;
6364 const root = findRoot(env.cwd);
64− if (!root) throw new UsageError("give --server <url>, or run this inside an agent's folder");
65+ if (!root) return TOKEN_SERVERS[0]!;
6566 return (JSON.parse(readFileSync(configPath(root), "utf8")) as { server: string }).server;
6667}
6768
@@ -166,7 +167,7 @@
166167 flags: { server: "string" },
167168 usage: "abso login [--server <url>]",
168169 about:
169− "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.",
170+ "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.",
170171 run: async (args, env) => {
171172 const server = boxServer(args, env);
172173 const record = await login(server, { say: (line) => process.stderr.write(`${line}\n`) });
--- a/client/src/mcp.ts
+++ b/client/src/mcp.ts
@@ -9,7 +9,8 @@
99// The protocol is JSON-RPC 2.0, one message per line, with no library: the
1010// client uses nothing outside Node.
1111
12−import { resolve } from "node:path";
12+import { realpathSync } from "node:fs";
13+import { isAbsolute, relative, resolve, sep } from "node:path";
1314import { clientVersion } from "./client-version.ts";
1415import { commandTable, main } from "./main.ts";
1516
@@ -92,7 +93,8 @@
9293 },
9394 folder: {
9495 type: "string",
95− description: "The abso folder to run in (default: the folder this server started in).",
96+ description:
97+ "The abso folder to run in: the folder this server started in (the default), or one inside it.",
9698 },
9799 json: { type: "boolean", description: "Answer with the command's JSON (as --json) instead of its text." },
98100 ...flags,
@@ -103,6 +105,50 @@
103105 });
104106}
105107
108+/** A path as it really is (through links), or as given when it doesn't exist. */
109+function real(path: string): string {
110+ try {
111+ return realpathSync.native(path);
112+ } catch {
113+ return path;
114+ }
115+}
117+/** Whether `path` is `start` or inside it, after links are followed. */
118+function inside(start: string, path: string): boolean {
119+ const rel = relative(real(start), real(path));
120+ return rel === "" || (rel !== ".." && !rel.startsWith(`..${sep}`) && !isAbsolute(rel));
121+}
123+/**
124+ * Where a tool call runs, and what it may read (Security on 233): its folder and
125+ * every --attach file stay inside the folder the server started in. A relative
126+ * path that climbs out (..), an absolute one elsewhere, or a link out is
127+ * refused, so no tool reads a file outside the project. Answers the folder, or
128+ * why the call is refused.
129+ */
130+export function confineCall(
131+ start: string,
132+ input: Readonly<Record<string, unknown>>,
133+): { folder: string } | { refused: string } {
134+ const named = typeof input.folder === "string" && input.folder !== "" ? input.folder : undefined;
135+ const folder = named === undefined ? start : resolve(start, named);
136+ if (!inside(start, folder))
137+ return {
138+ refused: `folder ${JSON.stringify(named)} is outside ${start}, the folder this server started in; tools run there or below`,
139+ };
140+ if (typeof input.attach === "string")
141+ for (const p of input.attach
142+ .split(",")
143+ .map((x) => x.trim())
144+ .filter((x) => x !== ""))
145+ if (!inside(start, resolve(folder, p)))
146+ return {
147+ refused: `--attach ${p} is outside ${start}, the folder this server started in; a tool attaches files from there or below`,
148+ };
149+ return { folder };
150+}
106152/** The command line a tool call stands for: flags as --name=value, then the words after --. */
107153export function argvFor(command: string, input: Readonly<Record<string, unknown>>): string[] {
108154 const def = commandTable()[command]!;
@@ -158,7 +204,9 @@
158204 const command = MCP_COMMANDS.find((c) => toolName(c) === name);
159205 if (command === undefined) return fail(id, -32602, `no tool ${JSON.stringify(name)}; tools/list names them`);
160206 const args = (params.arguments ?? {}) as Record<string, unknown>;
161− const folder = typeof args.folder === "string" && args.folder !== "" ? resolve(cwd, args.folder) : cwd;
207+ const where = confineCall(cwd, args);
208+ if ("refused" in where) return reply(id, { content: [{ type: "text", text: where.refused }], isError: true });
209+ const folder = where.folder;
162210 let streamed = "";
163211 const result = await main(argvFor(command, args), {
164212 cwd: folder,
--- a/client/test/client.test.ts
+++ b/client/test/client.test.ts
@@ -48,8 +48,8 @@
4848import { absolute, writeFileAtomic } from "../src/folder.ts";
4949import { runHook } from "../src/hook.ts";
5050import { tryFolderLock } from "../src/lock.ts";
51−import { commandTable, main } from "../src/main.ts";
52−import { argvFor } from "../src/mcp.ts";
51+import { boxServer, commandTable, main } from "../src/main.ts";
52+import { argvFor, confineCall, mcpTools } from "../src/mcp.ts";
5353import { pulledText } from "../src/queue.ts";
5454import { noteText, titleLine } from "../src/review.ts";
5555import { screenAnswer, throughLink, unsafeLink, unsafePath } from "../src/safety.ts";
@@ -2641,6 +2641,56 @@
26412641 assert.deepEqual(parsed.positionals, ["--server=x"]);
26422642 });
26432643
2644+ it("keeps a tool call's folder and --attach files inside the folder the server started in (Security on 233)", async () => {
2645+ const { folders } = await project({ "a.txt": "one\n" }, "alice");
2646+ const start = folders.alice!;
2647+ const refused = (input: Record<string, unknown>) => {
2648+ const r = confineCall(start, input);
2649+ return "refused" in r ? r.refused : "";
2650+ };
2651+ assert.deepEqual(confineCall(start, {}), { folder: start });
2652+ assert.deepEqual(confineCall(start, { folder: "sub" }), { folder: join(start, "sub") });
2653+ assert.deepEqual(confineCall(start, { attach: "a.txt, sub/b.png" }), { folder: start });
2654+ assert.match(refused({ folder: ".." }), /^folder "\.\." is outside .*, the folder this server started in/);
2655+ assert.match(refused({ folder: dirname(start) }), /is outside/);
2656+ assert.match(refused({ folder: "sub/../.." }), /is outside/);
2657+ assert.match(refused({ attach: "a.txt,../x.png" }), /^--attach \.\.\/x\.png is outside/);
2658+ assert.match(refused({ attach: join(tmpdir(), "x.png") }), /is outside/);
2659+ assert.match(refused({ folder: "sub", attach: "../../x.png" }), /is outside/);
2660+ assert.deepEqual(confineCall(start, { folder: "sub", attach: "../a.txt" }), { folder: join(start, "sub") });
2661+ const server = mcp(start);
2662+ try {
2663+ const up = await server.call("tools/call", { name: "status", arguments: { folder: ".." } });
2664+ assert.equal(up.result.isError, true);
2665+ assert.match(up.result.content[0].text, /is outside/);
2666+ const attach = await server.call("tools/call", {
2667+ name: "issue",
2668+ arguments: { args: ["1"], comment: "see", attach: "../../secret.png" },
2669+ });
2670+ assert.equal(attach.result.isError, true);
2671+ assert.match(attach.result.content[0].text, /^--attach \.\.\/\.\.\/secret\.png is outside/);
2672+ } finally {
2673+ server.close();
2674+ }
2675+ });
2677+ it("serves no -file twin, so no tool reads its text from a file", () => {
2678+ for (const tool of mcpTools())
2679+ for (const key of Object.keys(tool.inputSchema.properties as object))
2680+ assert.ok(!key.endsWith("-file") && key !== "file", `${tool.name} takes ${key}`);
2681+ });
2683+ it("abso login, box and logout outside a folder act on https://api.abso.dev", () => {
2684+ const outside = mkdtempSync(join(tmpdir(), "abso-login-"));
2685+ try {
2686+ assert.equal(boxServer(parseArgs("login", [], { server: "string" }), { cwd: outside }), "https://api.abso.dev");
2687+ const given = parseArgs("login", ["--server", "https://example.test"], { server: "string" });
2688+ assert.equal(boxServer(given, { cwd: outside }), "https://example.test");
2689+ } finally {
2690+ rmSync(outside, { recursive: true, force: true });
2691+ }
2692+ });
26442694 it("publish --done takes the start note back once it is published", async () => {
26452695 const { folders } = await project({ "a.txt": "one\n" }, "alice");
26462696 assert.equal((await avcs(folders.alice!, "start", "Two", "a.txt")).exit, 0);