Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions apps/desktop/src/preview/BrowserSession.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe("BrowserSession", () => {
}).pipe(Effect.provide(layer)),
);

it.effect("grants clipboard-sanitized-write through both the request and check handlers", () =>
it.effect("grants only write-direction clipboard access through both handlers", () =>
Effect.gen(function* () {
const browserSessions = yield* BrowserSession.BrowserSession;
const partition = yield* browserSessions.getPartition("scope-a");
Expand All @@ -86,12 +86,7 @@ describe("BrowserSession", () => {
return granted;
};

for (const permission of [
"clipboard-read",
"clipboard-sanitized-write",
"notifications",
"geolocation",
]) {
for (const permission of ["clipboard-sanitized-write", "notifications"]) {
assert.isTrue(requestAllows(permission), `request handler should allow ${permission}`);
assert.isTrue(
checkHandler(null, permission) as boolean,
Expand All @@ -102,7 +97,11 @@ describe("BrowserSession", () => {
// `clipboard-write` is not a real Electron permission — the async write API
// uses `clipboard-sanitized-write` — so the stale name must not be granted,
// and unrelated permissions stay denied.
for (const permission of ["clipboard-write", "midi"]) {
//
// `clipboard-read` and `geolocation` are denied deliberately: preview tabs
// load arbitrary sites, and the agent can evaluate script inside them, so
// neither may be granted without the user seeing a prompt.
for (const permission of ["clipboard-write", "midi", "clipboard-read", "geolocation"]) {
assert.isFalse(requestAllows(permission), `request handler should deny ${permission}`);
assert.isFalse(
checkHandler(null, permission) as boolean,
Expand Down
12 changes: 10 additions & 2 deletions apps/desktop/src/preview/BrowserSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,18 @@ const PREVIEW_PARTITION_PREFIX = "persist:t3code-preview-";
// buttons — e.g. the Next.js / Vercel error overlay — fail with
// `Failed to execute 'writeText' on 'Clipboard': Write permission denied`.
const ALLOWED_PREVIEW_PERMISSIONS: ReadonlySet<string> = new Set([
"clipboard-read",
"clipboard-sanitized-write",
"notifications",
"geolocation",
// Deliberately NOT clipboard-read: that is the read direction of the
// clipboard, and the copy buttons this list exists for only ever write.
// Preview tabs load arbitrary sites and the agent can evaluate script in
// them, so granting it would hand whatever the user last copied - a
// password, an API key, a one-time code - to any page or injected
// instruction that asks for it.
//
// Deliberately NOT geolocation: nothing in the preview needs the user's
// physical location, and it is granted here to every site the agent opens.
//
// Deliberately NOT local-fonts: preview sessions run untrusted web content,
// and silently granting it would hand every page the user's installed-font
// fingerprint (and font file bytes via FontData.blob()). The app's own font
Expand Down
Loading