Skip to content

webview: fix mixed-case remote resource authorities - #341486

Merged
Dmitriy Vasyura (dmitrivMS) merged 1 commit into
mainfrom
agents/investigate-regression-reports-fix
Oct 14, 2026
Merged

Dmitriy Vasyura (dmitrivMS) merged 1 commit into
mainfrom
agents/investigate-regression-reports-fix

Conversation

@dmitrivMS

@dmitrivMS Dmitriy Vasyura (dmitrivMS) commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fix blank webviews in remote windows whose authority contains uppercase letters, such as wsl+Ubuntu and wsl+FedoraLinux-44.

Webview resource URLs carry the remote authority in an HTTPS hostname, which the browser lowercases. The remote-OS lookup compared this normalized authority with the connection authority using strict equality, so it skipped the environment lookup and rejected otherwise valid resources with 401.

Use the existing case-insensitive authority comparison for that lookup. Target-OS-specific path normalization, resource-root containment, and rejection of different authorities or unknown remote operating systems remain unchanged.

Regression cause

Introduced by b0240f4c8e — Fix remote webview resource path containment, included in 1.141.1 and subsequently adopted on main in #341342. The introducing commit is absent from 1.141.0, and the known-good 1.140.0 loader has no remote-OS gate.

Fixed issues

Fixes #341396
Fixes #341398
Fixes #341431
Fixes #341423
Fixes #341451
Fixes #341458
Fixes #341473
Fixes #341474
Fixes #341421
Fixes #341440
Fixes #341444
Fixes #341461
Fixes #341469
Fixes #341475
Fixes #341482

Compare remote authorities case-insensitively when resolving the target OS, matching browser hostname normalization without weakening resource-root containment. Add resource-message regression tests for mixed-case WSL and SSH authorities and access-denied controls.

Fixes #341396\nFixes #341398\nFixes #341431\nFixes #341423\nFixes #341451\nFixes #341458\nFixes #341473\nFixes #341474

Co-authored-by: Copilot <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 14, 2026 08:18
@dmitrivMS Dmitriy Vasyura (dmitrivMS) added webview Webview issues WSL Issue when using WSL labels Oct 14, 2026
@dmitrivMS Dmitriy Vasyura (dmitrivMS) added this to the 1.142.0 milestone Oct 14, 2026
@dmitrivMS Dmitriy Vasyura (dmitrivMS) added the candidate Issue identified as probable candidate for fixing in the next release label Oct 14, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The targeted fix preserves existing containment checks and includes comprehensive regression coverage.

0 open findings

What changed in this PR

Fixes remote webview resource loading when browsers lowercase mixed-case authorities.

Changes:

  • Uses case-insensitive authority comparison before remote OS lookup.
  • Adds regression and denial-path tests.
File Description
webviewElement.ts Corrects remote authority matching.
webviewElement.test.ts Tests mixed-case authorities and security boundaries.

🧠 Review effort: Balanced


💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@dmitrivMS
Dmitriy Vasyura (dmitrivMS) marked this pull request as ready for review October 14, 2026 08:28
@dmitrivMS

Dmitriy Vasyura (dmitrivMS) commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator Author

Live WSL validation: before / after

Tested the local Code OSS development build against the actual Ubuntu WSL2 distribution using WSL extension 0.104.3 and an isolated synthetic workspace/profile. This used the authorized temporary product configuration and the real signing dependency; webview authorization and path-containment checks were not bypassed.

  • Before (first screenshot): restored the original strict authority comparison. The remote workspace connected successfully, but Markdown preview stayed blank. Actual webview JavaScript/CSS requests returned 401, and renderer logs confirmed Webview.loadLocalResource - access denied for the lowercased wsl+ubuntu resource authority while the connection was wsl+Ubuntu.
  • After (second screenshot): restored the PR fix. The same preview rendered normally; its index.js and markdown.css returned 200, and automation asserted that the expected Markdown heading was visible.

Both runs produced screenshots, a Playwright trace, and captioned video.

Completed validation

Configuration Result
Actual WSL wsl+Ubuntu Passed Markdown rendering/reopen, 14 Linux resource cases, and 10 Windows-local resource cases
Actual WSL wsl+ubuntu Passed the same rendering and resource checks
Standalone local Windows window Passed Markdown rendering/reopen and 10 local resource cases

The live checks covered allowed reads, canonical path forwarding, out-of-root and sibling-prefix denial, encoded traversal, different remote authorities, Linux path/file case sensitivity, POSIX literal-backslash filenames, missing files, range responses (206), and actual backend ETag revalidation (304, served to the webview from its cache as 200). All expected resource responses and contents matched; outside-root sentinels were never disclosed.

Reviews: Astra/max and Opus 5.5/max found no significant production issues. Opus identified a capability stub in the additional tests that was not reached because no remote provider was registered; that test setup was corrected, positive Windows/macOS controls demonstrated the failure before the correction, and Opus confirmed the finding resolved.

Additional local tests: the three focused webview suites now pass 94 tests, including eight further regression cases beyond the merged PR. Per the maintainer's request, those additional test changes remain local; no follow-up branch or PR was created.

  • npm run build-fast -- --client-only — passed.
  • .\scripts\test.bat --run src\vs\workbench\contrib\webview\test\browser\webviewElement.test.ts --run src\vs\workbench\contrib\webview\test\browser\resourceLoading.test.ts --run src\vs\workbench\contrib\webview\test\electron-browser\webviewElement.test.ts --reporter dot — passed, 94 tests.
  • npm run typecheck-client — passed.
  • npm run eslint -- src\vs\workbench\contrib\webview\test\browser\webviewElement.test.ts — passed.
  • node --experimental-strip-types build\hygiene.ts src\vs\workbench\contrib\webview\test\browser\webviewElement.test.ts — passed.

Temporary product metadata, the copied signing dependency, isolated test profiles/helpers, and the owned WSL fixtures/server installation were removed after validation. The actual live targets were Windows and Ubuntu 26.04 WSL2; Windows/macOS remote OS behavior was covered by unit tests, not live SSH hosts. Both before/after dev runs emitted the same four generic startup-log errors, so these results certify the targeted webview scenarios rather than a globally error-free application startup.

Before: blank WSL Markdown preview with the original strict authority comparison and resource 401s

After: WSL Markdown preview renders with the PR fix and resource responses are 200

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

candidate Issue identified as probable candidate for fixing in the next release webview Webview issues WSL Issue when using WSL

Projects

None yet

3 participants