Repository navigation
webview: fix mixed-case remote resource authorities - #341486
Conversation
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]>
There was a problem hiding this comment.
🟢 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.
Live WSL validation: before / afterTested 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.
Both runs produced screenshots, a Playwright trace, and captioned video. Completed validation
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.
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. |


Summary
Fix blank webviews in remote windows whose authority contains uppercase letters, such as
wsl+Ubuntuandwsl+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