The best way to control Claude Code, Codex and more from any computer or phone
fix(server): Antigravity file writes cannot escape the workspace through a linked ancestor (#26184)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 27, 2026 at 18:42 UTC
82515785bb6ec7b1b14894016977117864627b33
2 files changed
+35
-17
apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.test.ts
+13
@@ -260,6 +260,19 @@ describe("AntigravityAdapterV2 client file system", () => {
260
).pipe(Effect.exit);
261
assert.isTrue(Exit.isFailure(linkedDirWrite), "a write under an escaping directory link");
262
assert.isFalse(yield* fileSystem.exists(path.join(outside, "new.txt")));
263
+ const nestedLinkedDirWrite = yield* writeTextFile(
264
+ {
265
+ sessionId: "mock-session-1",
266
+ path: path.join(workspace, "linked-dir", "a", "b", "file.txt"),
267
+ content: "planted",
268
+ },
269
+ context("fs/write_text_file"),
270
+ ).pipe(Effect.exit);
271
+ assert.isTrue(
272
+ Exit.isFailure(nestedLinkedDirWrite),
273
+ "a write to missing directories under an escaping directory link",
274
+ );
275
+ assert.isFalse(yield* fileSystem.exists(path.join(outside, "a")));
276
const insideLink = path.join(workspace, "inside-link.ts");
277
yield* fileSystem.symlink(insidePath, insideLink);
278
const viaInsideLink = yield* readTextFile(
apps/server/src/provider/acp/AntigravityClientFiles.ts
+22
-17
@@ -1,4 +1,5 @@
1
import * as Effect from "effect/Effect";
2
+import * as Option from "effect/Option";
3
import type * as FileSystem from "effect/FileSystem";
4
import type * as Path from "effect/Path";
5
import * as EffectAcpErrors from "effect-acp/errors";
@@ -25,23 +26,27 @@ const resolveClientFilePath = Effect.fn("AntigravityClientFiles.resolveClientFil
26
const outside = EffectAcpErrors.AcpRequestError.invalidParams(
27
`Path '${input.requestPath}' is outside the session workspace.`,
28
);
28
- const real = yield* input.fileSystem.realPath(resolved).pipe(
29
- Effect.catch(() =>
30
- Effect.gen(function* () {
31
- // Fall back to the parent only for missing files, never dangling or unreadable links.
32
- const entryExists = yield* input.fileSystem.readLink(resolved).pipe(
33
- Effect.as(true),
34
- Effect.catch(() => input.fileSystem.exists(resolved)),
35
- Effect.orElseSucceed(() => true),
36
- );
37
- if (entryExists) return yield* outside;
38
- const parent = yield* input.fileSystem
39
- .realPath(path.dirname(resolved))
40
- .pipe(Effect.orElseSucceed(() => path.dirname(resolved)));
41
- return path.join(parent, path.basename(resolved));
42
- }),
43
- ),
44
- );
29
+ // Canonicalize the deepest existing ancestor, so a link above missing directories cannot escape.
30
+ let candidate = resolved;
31
+ const missingSuffix: Array<string> = [];
32
+ let real: string;
33
+ while (true) {
34
+ const canonical = yield* input.fileSystem.realPath(candidate).pipe(Effect.option);
35
+ if (Option.isSome(canonical)) {
36
+ real = path.join(canonical.value, ...missingSuffix);
37
+ break;
38
+ }
39
+ // Walk up only past missing entries, never dangling or unreadable links.
40
+ const entryExists = yield* input.fileSystem.readLink(candidate).pipe(
41
+ Effect.as(true),
42
+ Effect.catch(() => input.fileSystem.exists(candidate)),
43
+ Effect.orElseSucceed(() => true),
44
+ );
45
+ const parent = path.dirname(candidate);
46
+ if (entryExists || parent === candidate) return yield* outside;
47
+ missingSuffix.unshift(path.basename(candidate));
48
+ candidate = parent;
49
+ }
50
const roots = yield* Effect.forEach(input.allowedRoots, (root) =>
51
input.fileSystem.realPath(root).pipe(Effect.orElseSucceed(() => root)),
52
);