[Webview] Service worker corrupts raw remoteAuthority containing - followed by four hex digits
- Dominant language
- TypeScript
- Stars
- 193k
- Forks
- 42.4k
- PR merge metrics
- PR metrics pending
Description
Does this issue occur when all extensions are disabled?: Yes
- VS Code Version: OpenVSCode Server 1.96.0
- OS Version: MacOS Tahoe 26.4.1 (25E253)
- Browser: Safari
## Summary
Webview resources return a synthetic service-worker 404 when the remote authority contains a hyphen followed by four hexadecimal characters, for example:
tf-0f553fad85e991041548bd71d5f5f722073022e5.example.com
The same absolute resource URL returns 200 when opened in a separate tab or when DevTools "Bypass for network" is enabled.
## Steps to reproduce
1. Serve VS Code for Web/OpenVSCode using an HTTPS hostname containing `-[0-9a-f]{4}`, such as `tf-0f55...example.com`.
2. Open Getting Started content containing images inside the VS Code webview.
3. Observe the image requests in DevTools.
4. The requests return 404 with Size shown as `(service worker)`.
5. Open the identical Request URL in a separate tab; it returns 200.
6. Enable Application → Service Workers → Bypass for network and reload; the embedded images now load.
## Root cause
The webview service worker's remoteAuthority branch sends `requestUrl.host` as a raw authority.
`webviewElement.ts` then unconditionally calls:
decodeAuthority(entry.authority)
`decodeAuthority` performs:
authority.replace(/-([0-9a-f]{4})/g, ...)
This assumes the authority was produced by `encodeAuthority`, but the remoteAuthority branch supplied a raw hostname.
For example:
tf-0f553fad...
→ tf3fad...
→ a different punycode hostname
The resource lookup therefore fails and the worker synthesizes 404. The embedded request never reaches the original HTTP server.
## Expected
Raw remoteAuthority values should be preserved exactly.
## Suggested fix
- Distinguish encoded vscode-resource authorities from raw remoteAuthority values in the service-worker message, and only call `decodeAuthority` for authorities explicitly marked as encoded.
- Alternatively, encode the raw remoteAuthority before sending it through the existing decoding path. Please add a regression test using a hostname such as `tf-0f55.example.com`.
## Workaround
Avoid public hostnames containing `-[0-9a-f]{4}`. For example, `tf0f55...example.com` works.
Screenshot of dev tools:
Contributor guide
Assessment
This issue has not been assessed yet.