Repository navigation
Browser: harden remote unlisted view networking - #345149
Merged
Ulugbek Abdullaev (ulugbekna) merged 2 commits intoOct 30, 2026
Merged
Ulugbek Abdullaev (ulugbekna) merged 2 commits into
Ulugbek Abdullaev (ulugbekna) merged 2 commits into
Conversation
Contributor
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: Kyle Cutler (@kycutler)Matched files:
Joaquín Ruales (@jruales)Matched files:
|
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Upgrade sockets lack early error handling and lifecycle tracking, allowing client resets to crash the host process and unauthenticated connections to remain open after proxy disposal.
2 open issues
What changed in this PR
This PR hardens networking for remote unlisted BrowserViews by adding authenticated WebSocket Upgrade forwarding and blocking routes that could bypass the selected remote network.
Changes:
- Adds HTTP Upgrade forwarding through
TunnelProxy, including IPv6 handling and cleanup after client cancellation. - Restricts non-proxied WebRTC UDP and denies external popups from remote unlisted views.
- Adds proxy and popup-policy regression tests, adjusts stream cleanup, and removes URL paths from proxy logs.
| File | Description |
|---|---|
src/vs/platform/tunnel/test/node/tunnelProxy.test.ts |
Tests Upgrade forwarding, IPv6, cancellation, and direct Duplex connections. |
src/vs/platform/tunnel/node/tunnelProxy.ts |
Implements authenticated Upgrade forwarding and adjusts cleanup and logging. |
src/vs/platform/browserView/test/common/browserView.test.ts |
Tests popup denial and gesture consumption for remote unlisted views. |
src/vs/platform/browserView/electron-main/browserView.ts |
Applies WebRTC restrictions and passes remote-network state to popup handling. |
src/vs/platform/browserView/common/browserView.ts |
Denies external popups for remote unlisted views while preserving listed-tab behavior. |
Review effort: Balanced
Forward ws:// Upgrade traffic through TunnelProxy, cancel abandoned upstream connections, and cover authenticated forwarding and teardown behavior. Co-authored-by: Copilot <[email protected]>
Disable non-proxied WebRTC UDP and prevent remote unlisted BrowserViews from escaping through external popups. Co-authored-by: Copilot <[email protected]>
Ulugbek Abdullaev (ulugbekna)
force-pushed
the
ulugbekna/agents/remote-browser-proxy-hardening
branch
from
October 30, 2026 09:34
dcb21b8 to
69f99fc
Compare
Benjamin Christopher Simmonds (benibenj)
approved these changes
Oct 30, 2026
Ulugbek Abdullaev (ulugbekna)
deleted the
ulugbekna/agents/remote-browser-proxy-hardening
branch
October 30, 2026 09:51
Ulugbek Abdullaev (ulugbekna)
added a commit
that referenced
this pull request
Oct 30, 2026
<!-- Thank you for submitting a Pull Request. Please: * Read our Pull Request guidelines: https://github.com/microsoft/vscode/wiki/How-to-Contribute#pull-requests * Associate an issue with the Pull Request. * Ensure that the code is up-to-date with the `main` branch. * Include a description of the proposed changes and how to test them. --> ## Prerequisite [#345149](#345149) merged into `main` and provides the generic WebSocket/WebRTC/popup hardening used here. This branch is rebased directly onto the merged commits. ## Summary This enables desktop canvases published by a remote Agent Host to render in the existing native BrowserView canvas editor. Remote canvas URLs retain their original URL, including `127.0.0.1`, while the BrowserView resolves the network from the exact owning session/chat. The canvas requires that network, preventing a disconnected, unsupported, or disabled remote from falling back to the client or an unrelated workspace remote. ## Architecture ```text Remote Agent Host publishes CanvasState.url │ ▼ AgentHostCanvasCollection projects the exact chat-owned canvas │ ▼ CanvasService creates an unlisted BrowserView for the owning chat │ ▼ SessionBrowserNetworkContribution resolves chat → session → host authority │ ▼ BrowserViewWorkbenchService requires that resolved network │ ▼ Existing authenticated Agent Host BrowserView proxy │ ▼ Remote Agent Host network, including its loopback canvas server ``` ### Fail-closed behavior - `CanvasService` supplies the exact chat owner and requests strict network resolution. - `BrowserViewWorkbenchService` resolves the owner even when remote proxying is disabled, then rejects if that network cannot be used. - Ambient remote Editor windows delegate TCP to their Agent Host connection. - Non-ambient remote hosts present canvases only in the Agents window, where owning-session resolution exists. - Local canvases retain their current behavior. ## How to review Review the two commits independently: ### 1. `canvases: enable remote Agent Host presentation` 1. Provider policy: - [`RemoteAgentHostSessionsProvider`](src/vs/sessions/contrib/providers/remoteAgentHost/browser/remoteAgentHostSessionsProvider.ts) - [`AgentHostChatContribution`](src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostChatContribution.ts) - [`RemoteAgentHostContribution`](src/vs/workbench/contrib/chat/browser/remoteAgentHost/remoteAgentHostChatContribution.ts) 2. Exact network requirement: - [`CanvasService.resolveCanvasModel`](src/vs/workbench/contrib/canvases/electron-browser/canvasService.ts) - [`BrowserViewWorkbenchService.createExternalBrowserView`](src/vs/workbench/contrib/browserView/electron-browser/browserViewWorkbenchService.ts) - focused test: `does not fall back when an external view requires its resolved network` 3. Ambient remote Editor TCP: - [`EditorRemoteAgentHostServiceClient`](src/vs/workbench/services/agentHost/browser/editorRemoteAgentHostServiceClient.ts) Canvas enablement and strict routing intentionally remain in the same commit: enabling presentation without fail-closed ownership would create an unsafe intermediate state. ### 2. `canvases: add native remote network coverage` - [`browser.test.ts`](extensions/vscode-api-tests/src/singlefolder-tests/browser.test.ts) drives a real Electron BrowserView through redirect, SSE, `ws://`, an 8 MiB response, and WebRTC gathering. - It first disables remote proxying and verifies zero HTTP/WebSocket/UDP traffic. - It then enables proxying and verifies all browser protocols succeed with zero UDP/STUN leakage. ## Validation - `npm run build-fast -- --client-only` — passed - `npm run typecheck-client` — passed - Provider, canvas, chat contribution, and ambient remote client suites — 1,824 passed - Changed TypeScript ESLint — passed for 13 files - `npm run valid-layers-check` — passed - `npm run gulp compile-extension:vscode-api-tests` — passed with 0 errors - `./scripts/test-integration.sh --suite api-folder --grep "remote Agent Host network loads native Chromium protocols and fails closed"` — 1 passed - `git diff origin/main..HEAD --check` — passed ## Manual dogfood Verified against a Windows `devbox2` Remote Agent Host through an authenticated dev tunnel: - the remote agent discovered and opened the Session timeline canvas; - the BrowserView rendered while retaining its remote loopback URL; - that port had no listener on the Mac and direct local `curl` failed, confirming traffic crossed the Agent Host proxy; - closing, reopening, and interacting with the canvas succeeded. ## Scope and limitations - Desktop native BrowserViews only. - Copilot Agent Host canvas channels only. - No public extension API changes. - No relay transport support without negotiated TCP forwarding. - Non-ambient remote hosts present canvases only in the Agents window.
Kyle Cutler (kycutler)
added a commit
that referenced
this pull request
Oct 30, 2026
* Browser: Tighten remote canvas networking Follow-up to #345102 and #345149: - Offer canvases on remote agent hosts only while browser remote proxying is enabled and the host can forward TCP; an unknown host, such as a disconnected one, keeps its canvases. - Require an embedded view's owner network whenever an owner is given, instead of a separate flag. - Remove the WebSocket upgrade handler from the tunnel proxy: Chromium always tunnels WebSockets, including ws://, through CONNECT. - Replace the extension test commands with unit coverage for failing closed, gating, and large and WebSocket traffic over agent host streams. Co-authored-by: Copilot <[email protected]> * Browser: Address remote canvas review feedback Resolve an embedded view's owner network before any asynchronous work and reject unknown agent owners instead of falling back to the local network. Gate remote editor-window canvases reactively on remote browser proxying. Cover the browser proxy over real Agent Host TCP and Chromium's remote WebSocket, large-response and WebRTC UDP behavior in the remote API suite. Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
Dmitrii F. (lingeniare)
pushed a commit
to lingeniare/vegaide
that referenced
this pull request
Nov 7, 2026
<!-- Thank you for submitting a Pull Request. Please: * Read our Pull Request guidelines: https://github.com/microsoft/vscode/wiki/How-to-Contribute#pull-requests * Associate an issue with the Pull Request. * Ensure that the code is up-to-date with the `main` branch. * Include a description of the proposed changes and how to test them. --> ## Prerequisite [microsoft/vscode#345149](microsoft/vscode#345149) merged into `main` and provides the generic WebSocket/WebRTC/popup hardening used here. This branch is rebased directly onto the merged commits. ## Summary This enables desktop canvases published by a remote Agent Host to render in the existing native BrowserView canvas editor. Remote canvas URLs retain their original URL, including `127.0.0.1`, while the BrowserView resolves the network from the exact owning session/chat. The canvas requires that network, preventing a disconnected, unsupported, or disabled remote from falling back to the client or an unrelated workspace remote. ## Architecture ```text Remote Agent Host publishes CanvasState.url │ ▼ AgentHostCanvasCollection projects the exact chat-owned canvas │ ▼ CanvasService creates an unlisted BrowserView for the owning chat │ ▼ SessionBrowserNetworkContribution resolves chat → session → host authority │ ▼ BrowserViewWorkbenchService requires that resolved network │ ▼ Existing authenticated Agent Host BrowserView proxy │ ▼ Remote Agent Host network, including its loopback canvas server ``` ### Fail-closed behavior - `CanvasService` supplies the exact chat owner and requests strict network resolution. - `BrowserViewWorkbenchService` resolves the owner even when remote proxying is disabled, then rejects if that network cannot be used. - Ambient remote Editor windows delegate TCP to their Agent Host connection. - Non-ambient remote hosts present canvases only in the Agents window, where owning-session resolution exists. - Local canvases retain their current behavior. ## How to review Review the two commits independently: ### 1. `canvases: enable remote Agent Host presentation` 1. Provider policy: - [`RemoteAgentHostSessionsProvider`](src/vs/sessions/contrib/providers/remoteAgentHost/browser/remoteAgentHostSessionsProvider.ts) - [`AgentHostChatContribution`](src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostChatContribution.ts) - [`RemoteAgentHostContribution`](src/vs/workbench/contrib/chat/browser/remoteAgentHost/remoteAgentHostChatContribution.ts) 2. Exact network requirement: - [`CanvasService.resolveCanvasModel`](src/vs/workbench/contrib/canvases/electron-browser/canvasService.ts) - [`BrowserViewWorkbenchService.createExternalBrowserView`](src/vs/workbench/contrib/browserView/electron-browser/browserViewWorkbenchService.ts) - focused test: `does not fall back when an external view requires its resolved network` 3. Ambient remote Editor TCP: - [`EditorRemoteAgentHostServiceClient`](src/vs/workbench/services/agentHost/browser/editorRemoteAgentHostServiceClient.ts) Canvas enablement and strict routing intentionally remain in the same commit: enabling presentation without fail-closed ownership would create an unsafe intermediate state. ### 2. `canvases: add native remote network coverage` - [`browser.test.ts`](extensions/vscode-api-tests/src/singlefolder-tests/browser.test.ts) drives a real Electron BrowserView through redirect, SSE, `ws://`, an 8 MiB response, and WebRTC gathering. - It first disables remote proxying and verifies zero HTTP/WebSocket/UDP traffic. - It then enables proxying and verifies all browser protocols succeed with zero UDP/STUN leakage. ## Validation - `npm run build-fast -- --client-only` — passed - `npm run typecheck-client` — passed - Provider, canvas, chat contribution, and ambient remote client suites — 1,824 passed - Changed TypeScript ESLint — passed for 13 files - `npm run valid-layers-check` — passed - `npm run gulp compile-extension:vscode-api-tests` — passed with 0 errors - `./scripts/test-integration.sh --suite api-folder --grep "remote Agent Host network loads native Chromium protocols and fails closed"` — 1 passed - `git diff origin/main..HEAD --check` — passed ## Manual dogfood Verified against a Windows `devbox2` Remote Agent Host through an authenticated dev tunnel: - the remote agent discovered and opened the Session timeline canvas; - the BrowserView rendered while retaining its remote loopback URL; - that port had no listener on the Mac and direct local `curl` failed, confirming traffic crossed the Agent Host proxy; - closing, reopening, and interacting with the canvas succeeded. ## Scope and limitations - Desktop native BrowserViews only. - Copilot Agent Host canvas channels only. - No public extension API changes. - No relay transport support without negotiated TCP forwarding. - Non-ambient remote hosts present canvases only in the Agents window.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
This closes two generic network-containment gaps for unlisted BrowserViews using a remote Agent Host network:
ws://) throughTunnelProxy, including IPv6 literals and client cancellation while the upstream dial is pending.The changes are independent of canvas enablement and apply to any remote unlisted BrowserView.
How to review
Review the two commits independently:
1.
browser: proxy authenticated WebSocket upgradesTunnelProxy._onUpgradeauthenticates the proxy request, validates an absolute HTTP URL, normalizes IPv6 literals, forwards the origin-form request, and bridges the established stream.tunnelProxy.test.tscovers successful Upgrade forwarding, IPv6 normalization, and abandoned connections.2.
browser: contain remote unlisted viewsBrowserViewappliesdisable_non_proxied_udpwhen its browser session has a remote network.getBrowserViewPopupActiondenies external popup escape for unlisted remote views while preserving listed browser-tab behavior and consuming the initiating gesture.Security properties
http:request target.Validation
npm run build-fast -- --client-only— passednpm run typecheck-client— passed./scripts/test.sh --run src/vs/platform/tunnel/test/node/tunnelProxy.test.ts --run src/vs/platform/browserView/test/common/browserView.test.ts— 42 passedgit diff origin/main..HEAD --check— passed