Skip to content

Warn before attaching browser content from possibly untrusted sources#308286

Merged
kycutler merged 1 commit intomainfrom
kycutler/attachtrust
Apr 7, 2026
Merged

Warn before attaching browser content from possibly untrusted sources#308286
kycutler merged 1 commit intomainfrom
kycutler/attachtrust

Conversation

@kycutler
Copy link
Copy Markdown
Contributor

@kycutler kycutler commented Apr 7, 2026

No description provided.

Copilot AI review requested due to automatic review settings April 7, 2026 18:18
@kycutler kycutler enabled auto-merge (squash) April 7, 2026 18:18
@kycutler kycutler added this to the 1.116.0 milestone Apr 7, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

Screenshot Changes

Base: fc99d59e Current: 057386c4

Changed (4)

chat/aiCustomizations/aiCustomizationManagementEditor/PromptsTab/Dark
Before After
before after
chat/aiCustomizations/aiCustomizationManagementEditor/McpBrowseMode/Light
Before After
before after
chat/aiCustomizations/aiCustomizationManagementEditor/PromptsTabScrolled/Light
Before After
before after
chat/aiCustomizations/aiCustomizationManagementEditor/McpServersTabNarrow/Light
Before After
before after

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a user warning/confirmation step before attaching Integrated Browser content to chat when the current page may be untrusted, helping mitigate prompt-injection risks from arbitrary web pages.

Changes:

  • Added an “untrusted content” confirmation dialog with a “Don’t show again” preference.
  • Included the current browser URL in IElementData to enable trust checks per element.
  • Refactored element-selection cancellation cleanup and moved “element added” telemetry to the attachment path.
Show a summary per file
File Description
src/vs/workbench/contrib/browserView/electron-browser/features/browserEditorChatFeatures.ts Adds warning dialog + persisted preference, hooks it into element/console-log attachments, and refactors selection lifecycle/telemetry.
src/vs/platform/browserView/electron-main/browserViewElementInspector.ts Augments extracted element data with the current page URL.
src/vs/platform/browserElements/common/browserElements.ts Extends IElementData to optionally carry the source URL.

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 2

Comment on lines +187 to +188
// Query the workspace trust service for file URLs
const trustInfo = await this.workspaceTrustManagementService.getUriTrustInfo(URI.file(parsedUrl.pathname));
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For file: URLs, using URI.file(parsedUrl.pathname) is likely to produce the wrong URI on Windows and/or for percent-encoded paths (e.g. spaces become %20), which can cause getUriTrustInfo to misclassify a trusted local file as untrusted. Consider using URI.parse(url) (or otherwise properly decoding the file URL) when passing it to getUriTrustInfo so the trust check matches the actual resource URI.

Suggested change
// Query the workspace trust service for file URLs
const trustInfo = await this.workspaceTrustManagementService.getUriTrustInfo(URI.file(parsedUrl.pathname));
// Query the workspace trust service for file URLs using the original file URL semantics
const trustInfo = await this.workspaceTrustManagementService.getUriTrustInfo(URI.parse(url));

Copilot uses AI. Check for mistakes.
Comment on lines 341 to +359
@@ -322,10 +354,29 @@ export class BrowserEditorChatIntegration extends BrowserEditorContribution {
});
}

if (!await this._confirmContentAttachmentRisk(elementData.url ?? model.url)) {
return;
}
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_attachElementDataToChat captures the screenshot (and builds the attachment payload) before showing the untrusted-content warning. If the user cancels, we still did the expensive captureScreenshot call and temporarily collected page content. Consider calling _confirmContentAttachmentRisk(...) earlier (before building toAttach and especially before captureScreenshot) to avoid unnecessary work and better align with “warn before attaching”.

Copilot uses AI. Check for mistakes.
@vs-code-engineering
Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

@jruales

Matched files:

  • src/vs/platform/browserView/electron-main/browserViewElementInspector.ts
  • src/vs/workbench/contrib/browserView/electron-browser/features/browserEditorChatFeatures.ts

@kycutler kycutler merged commit 308b3b9 into main Apr 7, 2026
27 checks passed
@kycutler kycutler deleted the kycutler/attachtrust branch April 7, 2026 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants