The best way to control Claude Code, Codex and more from any computer or phone
fix(server): agents can read documents a guest attaches (#29760)
Co-authored-by: maria-rcks <maria@kuuro.net> Co-authored-by: Julius Marminge <julius0216@outlook.com>
Alex Southwell committed
Nov 15, 2026 at 03:27 UTC
d109866c631ba40367f2a6bc1cbc6a9d2faaa822
2 files changed
+39
-4
apps/server/src/guest/GuestShareService.test.ts
+30
-3
@@ -51,6 +51,7 @@ import * as ProjectionStore from "../orchestration-v2/ProjectionStore.ts";
51
import * as ProviderAdapterRegistry from "../orchestration-v2/ProviderAdapterRegistry.ts";
52
import * as ResourceCleanupService from "../orchestration-v2/ResourceCleanupService.ts";
53
import * as ProviderReplayHarness from "../orchestration-v2/testkit/ProviderReplayHarness.ts";
54
+import * as DocumentText from "../provider/DocumentText.ts";
55
import * as ProviderRegistry from "../provider/ProviderRegistry.ts";
56
import * as ServerSettings from "../serverSettings.ts";
57
import * as AnalyticsService from "../telemetry/AnalyticsService.ts";
@@ -148,6 +149,7 @@ const layerTest = GuestShareService.layer.pipe(
149
Layer.provide(layerConnect),
150
Layer.provideMerge(layerAnalytics),
151
Layer.provide(ServerSecretStore.layer),
152
+ Layer.provide(DocumentText.layer),
153
Layer.provideMerge(layerConfig),
154
Layer.provideMerge(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer)),
155
);
@@ -731,6 +733,11 @@ it.effect("refuses too many files, too many bytes, and images that are not what
733
contentType: "text/html",
734
bytes: new TextEncoder().encode("<b>"),
735
},
736
+ {
737
+ name: "notes.rtf",
738
+ contentType: "application/rtf",
739
+ bytes: new TextEncoder().encode(String.raw`{\rtf1 Available}`),
740
+ },
741
]),
742
);
743
const [message] = yield* waitingMessages;
@@ -744,26 +751,46 @@ it.effect("refuses too many files, too many bytes, and images that are not what
751
[
752
{ type: "image", name: "screen.png", mimeType: "image/png", sizeBytes: PNG.length },
753
{ type: "file", name: "notes_fdp.html", mimeType: "text/html", sizeBytes: 3 },
754
+ { type: "file", name: "notes.rtf", mimeType: "application/rtf", sizeBytes: 17 },
755
],
756
);
757
+ // Agents read a guest's documents through the same extracted text as the owner's uploads.
758
+ const { attachmentsDir } = yield* ServerConfig.ServerConfig;
759
+ const document = resolveAttachmentPath({
760
+ attachmentsDir,
761
+ attachment: message!.attachments![2]!,
762
+ });
763
+ assert.equal(
764
+ yield* (yield* FileSystem.FileSystem).readFileString(`${document}.txt`),
765
+ "Available",
766
+ );
767
}).pipe(Effect.scoped, Effect.provide(layerTest)),
768
);
769
770
it.effect("caps the bytes of files waiting in one share", () =>
771
Effect.gen(function* () {
772
const { guestShares, session, shareId } = yield* joinedGuest;
755
- const submit = (sizeBytes: number) =>
773
+ const submit = (sizeBytes: number, ...more: Parameters<typeof uploadsOf>[0]) =>
774
Effect.gen(function* () {
775
return guestShares.submit(
776
session,
777
{ shareId, text: "Look" },
760
- yield* uploadsOf([png("big.png", sizeBytes)]),
778
+ yield* uploadsOf([png("big.png", sizeBytes), ...more]),
779
);
780
}).pipe(Effect.flatten);
781
yield* submit(9 * MIB);
782
yield* submit(9 * MIB);
765
- const error = yield* Effect.flip(submit(9 * MIB));
783
+ const before = yield* storedFiles;
784
+ const error = yield* Effect.flip(
785
+ submit(9 * MIB, {
786
+ name: "notes.rtf",
787
+ contentType: "application/rtf",
788
+ bytes: new TextEncoder().encode(String.raw`{\rtf1 Available}`),
789
+ }),
790
+ );
791
assert.equal(error.reason, "files_busy");
792
+ // The refused message keeps neither its files nor their extracted text.
793
+ assert.deepEqual(yield* storedFiles, before);
794
// Text alone still goes through.
795
yield* guestShares.submit(session, { shareId, text: "One more thing" }, []);
796
assert.equal((yield* waitingMessages).length, 3);
apps/server/src/guest/GuestShareService.ts
+9
-1
@@ -55,6 +55,7 @@ import {
55
projectTurnItemForWire,
56
threadStreamEventItem,
57
} from "../orchestration-v2/WireProjection.ts";
58
+import * as DocumentText from "../provider/DocumentText.ts";
59
import * as ProviderRegistry from "../provider/ProviderRegistry.ts";
60
import * as ServerSettings from "../serverSettings.ts";
61
import * as AnalyticsService from "../telemetry/AnalyticsService.ts";
@@ -227,6 +228,7 @@ const make = Effect.gen(function* () {
228
const fileSystem = yield* FileSystem.FileSystem;
229
const random = yield* SecureRandom.SecureRandom;
230
const analytics = yield* AnalyticsService.AnalyticsService;
231
+ const documents = yield* DocumentText.DocumentText;
232
const signer = yield* PayloadSigner.make(SIGNING_SECRET_NAME);
233
/** A truncated HMAC keeps invite links short. 128 bits is still far beyond guessing range. */
234
const inviteSignature = (shareId: string) =>
@@ -393,7 +395,12 @@ const make = Effect.gen(function* () {
395
const path = resolveAttachmentPath({ attachmentsDir, attachment });
396
return path === null
397
? Effect.void
396
- : fileSystem.remove(path, { force: true }).pipe(Effect.ignore);
398
+ : fileSystem
399
+ .remove(path, { force: true })
400
+ .pipe(
401
+ Effect.andThen(fileSystem.remove(`${path}.txt`, { force: true })),
402
+ Effect.ignore,
403
+ );
404
},
405
{ discard: true },
406
);
@@ -439,6 +446,7 @@ const make = Effect.gen(function* () {
446
yield* fileSystem.makeDirectory(attachmentsDir, { recursive: true });
447
yield* fileSystem.copyFile(uploads[index]!.path, path);
448
stored.push(attachment);
449
+ yield* documents.ensure(path);
450
}).pipe(Effect.mapError(() => uploadFailed)),
451
{ discard: true },
452
).pipe(Effect.onError(() => removeStored(stored)));