fix(desktop): stop granting preview content clipboard-read and geolocation #8291
main fromrefs/pull/8291/head·opened View on GitHubProblem#
Every preview partition auto-approves a fixed permission set through both the request handler and the check handler, with no prompt and no origin restriction:
const ALLOWED_PREVIEW_PERMISSIONS: ReadonlySet<string> = new Set([
"clipboard-read",
"clipboard-sanitized-write",
"notifications",
"geolocation",
The comment above the set explains the list exists so built-in "Copy" buttons — the Next.js / Vercel error overlay — keep working. Those only ever write. clipboard-read is the read direction, and in Electron it reads the real OS clipboard.
Preview tabs accept any absolute http(s) URL, so arbitrary sites land in this partition, and the agent can evaluate script inside them via preview_evaluate. That gives two paths to the same disclosure: a hostile page calling navigator.clipboard.readText() where Chrome would normally prompt, and an injected agent reading the clipboard into its own context. Either way the user's clipboard contents are readable without them being asked.
geolocation was granted the same way, to every site the agent opens, and nothing in the preview needs it.
Fix#
Drop clipboard-read and geolocation. Keep clipboard-sanitized-write and notifications, so the copy buttons the list was added for keep working. Comments record why each is deliberately absent, in the same style as the existing local-fonts note.
Tests now assert both are denied by both handlers.
Note for reviewers#
evaluateWithDebugger sends every Runtime.evaluate with userGesture: true, which manufactures the transient user activation that permission-gated APIs check. That is a separate concern with ~10 call sites, some of which may rely on it, so it is not touched here.
Verification#
vp test run apps/desktop/src/preview/BrowserSession.test.ts— 6 passedvp run --filter @t3tools/desktop typecheck— cleanvp fmt --check,vp lint,git diff --checkon the changed files — clean
Found during a security review of the repository.
Model: Claude Opus 5 · Harness: Claude Code
Note
Low Risk Narrows permission auto-approval in preview sessions with targeted test coverage; copy-to-clipboard for overlays should remain via clipboard-sanitized-write.
Overview Tightens auto-granted Electron permissions for desktop preview browser partitions so untrusted preview URLs and agent-injected script cannot read the OS clipboard or access geolocation without a user prompt.
ALLOWED_PREVIEW_PERMISSIONS now only includes clipboard-sanitized-write and notifications (dropped clipboard-read and geolocation). Inline comments document why read-direction clipboard and location are excluded, matching the existing local-fonts rationale. BrowserSession.test.ts is updated to expect allow for write clipboard + notifications and explicit deny for clipboard-read, geolocation, and other unrelated permissions on both the request and check handlers.
Note
Remove clipboard-read and geolocation from preview permissions in BrowserSession#
Trims the ALLOWED_PREVIEW_PERMISSIONS constant in BrowserSession.ts so only clipboard-sanitized-write and notifications remain granted. Comments explain why read-direction clipboard and geolocation are excluded. Tests in BrowserSession.test.ts are updated to assert denial of both removed permissions.
- Behavioral Change: preview permission handlers now deny
clipboard-readandgeolocationwhere they previously allowed them.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
Approvability#
Verdict: Not approved
Macroscope's review found this PR not approvable — This PR changes the production Electron permission defaults for preview content, removing automatic access to clipboard contents and geolocation while preserving write-only clipboard behavior. Although the diff is small and has targeted tests, the sensitive-data and product-default impact warrants human review.
Notes:
- Diff unchanged. Approvability was decided on eligibility alone.
juliusmarminge added labelsmacroscope-review
Note
Written by
claude-opus-5-5on behalf of MariaHi! We are cleaning up open PRs, and this one appears to have been created with an older model (
opus 5). If this change is really important, we recommend rebuilding the PR with a newer model if possible.maria-rcks closed this
Sign in to join this conversation.
Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
4227c03b-cbc8-4a7b-9334-c7504e02e6adYou can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
Comment `@coderabbitai help` to get the list of available commands.