Skip to content

Visual Studio Code, rebuilt in Rust

Rust

feat(windows): refuse UNC hosts that are not allowed

rokartur15320dbf0f62
diff --git a/native/crates/app/src/editor.rs b/native/crates/app/src/editor.rs
index 8348c71a58b..df2afe8cadc 100644
--- a/native/crates/app/src/editor.rs
+++ b/native/crates/app/src/editor.rs
@@ -153,6 +153,7 @@ impl TextDocument {
}
pub fn read(path: &Path, languages: &Languages, settings: &Settings) -> std::io::Result<Self> {
+ files::unc::check_unc_access(path)?;
let bytes = std::fs::read(path)?;
Ok(Self::from_bytes("file", path, &bytes, None, languages, settings))
}
diff --git a/native/crates/app/src/main.rs b/native/crates/app/src/main.rs
index aa1ea9a0186..0b6adb75bbb 100644
--- a/native/crates/app/src/main.rs
+++ b/native/crates/app/src/main.rs
@@ -261,6 +261,7 @@ fn main() -> anyhow::Result<()> {
perf::mark("code/didScanExtensions");
// Artur: user extensions live in ~/.vsrustium/extensions, the default user data dir's extensions folder.
let extensions_folder = flag_value("--extensions-dir").map_or_else(|| user_data.join("extensions"), PathBuf::from);
+ configure_unc_access(&user_data, &extensions_folder);
// code/electron-main/main.ts `initServices` makes the extensions folder; the extensions watcher watches it.
std::fs::create_dir_all(&extensions_folder)?;
UserExtensions::new(extensions_folder.clone(), &VERSION).clean_up()?;
@@ -983,6 +984,20 @@ fn open_shared_storage(shared_data: Option<PathBuf>) -> anyhow::Result<storage::
Ok(storage::Storage::open(&dir.join("state.vscdb")))
}
+/// app.ts "UNC Host Allowlist" from the user's settings, and main.ts `allowWindowsUNCPath` of the extensions folder.
+fn configure_unc_access(user_data: &Path, extensions_folder: &Path) {
+ let user_settings = Settings::load(Registry::with_extensions(&[]), user_data.join("User"), None);
+ let setting = |key: &str| user_settings.get_value(Some(key), &Overrides::default());
+ if setting("security.restrictUNCAccess") == Some(json!(false)) {
+ files::unc::disable_unc_access_restrictions();
+ } else {
+ files::unc::add_unc_hosts_to_allowlist(&setting("security.allowedUNCHosts").unwrap_or_default());
+ }
+ if let Some(host) = files::unc::unc_host(&extensions_folder.to_string_lossy()) {
+ files::unc::add_unc_host_to_allowlist(host);
+ }
+}
+
/// main.ts `resolveShellEnv` merged into `process.env`: a Dock launch gets the login shell's PATH for the host,
/// terminals and tasks. Runs before any thread starts, so changing the environment is sound.
#[cfg(unix)]
diff --git a/native/crates/app/src/webview.rs b/native/crates/app/src/webview.rs
index 71f2e4a0524..7ff4a0ce811 100644
--- a/native/crates/app/src/webview.rs
+++ b/native/crates/app/src/webview.rs
@@ -172,6 +172,10 @@ fn is_contained_on(resource: &files::Resource, roots: &[files::Resource], window
if resource.scheme != "file" {
return true;
}
+ // The file service's read refuses the host (diskFileSystemProvider.ts), before canonicalize reaches it.
+ if files::unc::check_unc_access(Path::new(&path)).is_err() {
+ return false;
+ }
match (std::fs::canonicalize(&path), std::fs::canonicalize(fs_path(root))) {
(Ok(real), Ok(real_root)) => real.starts_with(real_root),
_ => true,
diff --git a/native/crates/app/src/workbench/text_files.rs b/native/crates/app/src/workbench/text_files.rs
index 03a8da7ff25..892c17ffcf3 100644
--- a/native/crates/app/src/workbench/text_files.rs
+++ b/native/crates/app/src/workbench/text_files.rs
@@ -169,6 +169,7 @@ impl Workbench {
/// A model of a disk provider's resource (`on_disk`), its stat kept for the save conflict check.
pub(super) fn read_document(&mut self, scheme: &str, path: &Path) -> std::io::Result<TextDocument> {
+ files::unc::check_unc_access(path)?;
let bytes = std::fs::read(path)?;
if let Some(stat) = stat(path) {
self.text_files.stats.insert((scheme.to_string(), path.to_path_buf()), stat);
@@ -185,6 +186,9 @@ impl Workbench {
let empty = |error| TextDocument { open_error: Some(error), ..TextDocument::from_text(scheme, path, "", "utf8".into(), None, &self.languages, &settings) };
let overrides = Overrides { resource: Some(path), ..Overrides::default() };
let limit_mb = settings.get_value(Some("workbench.editorLargeFileConfirmation"), &overrides).and_then(|value| value.as_f64()).unwrap_or(1024.);
+ if files::unc::check_unc_access(path).is_err() {
+ return empty(OpenError::Failed);
+ }
if let Ok(metadata) = std::fs::metadata(path)
&& !unlimited
&& metadata.len() as f64 > limit_mb * 1024. * 1024.
@@ -313,6 +317,7 @@ impl Workbench {
{
return Err(SaveError::ModifiedSince);
}
+ files::unc::check_unc_access(path).map_err(|error| SaveError::Other(files::unc::provider_message(&error)))?;
if options.unlock {
// diskFileSystemProvider.ts `open` with `unlock`: the owner's write bit, errors logged only.
if let Err(error) = unlock(path) {
@@ -649,7 +654,7 @@ impl Workbench {
}
let Some(model) = self.editors.model(scheme, path) else { return Ok(()) };
let (was_dirty, encoding) = (model.is_dirty(), model.document().encoding.clone());
- let sent = match std::fs::read(path) {
+ let sent = match files::unc::check_unc_access(path).and_then(|()| std::fs::read(path)) {
Ok(bytes) => {
let sent = self.update_model(scheme, path, &encoding::decode(&bytes, &encoding), true, cx);
if let Some(stat) = stat(path) {
@@ -922,6 +927,7 @@ fn write_elevated(path: &Path, bytes: &[u8], unlock: bool) -> Result<(), SaveErr
}
fn stat(path: &Path) -> Option<Stat> {
+ files::unc::check_unc_access(path).ok()?;
let metadata = std::fs::metadata(path).ok()?;
Some((metadata.modified().ok()?, metadata.len()))
}
diff --git a/native/crates/config/src/registry.rs b/native/crates/config/src/registry.rs
index 0824253d4ca..936bb5d5e78 100644
--- a/native/crates/config/src/registry.rs
+++ b/native/crates/config/src/registry.rs
@@ -142,6 +142,9 @@ impl Registry {
unreachable!("port-settings.json holds an object")
};
settings.extend(port);
+ if cfg!(windows) {
+ settings.extend(windows_settings());
+ }
for (key, schema) in settings {
let scope = Scope::from_number(&schema["scope"]).unwrap_or(Scope::Window);
let restricted = schema["restricted"].as_bool().unwrap_or(false);
@@ -510,6 +513,34 @@ impl Registry {
}
}
+/// workbench/common/configuration.ts `DynamicWorkbenchSecurityConfiguration`: the UNC settings it registers on
+/// Windows only, so the macOS dump in core-settings.json has none.
+fn windows_settings() -> Map<String, Value> {
+ let section = json!({ "id": "security", "title": "Security", "order": 7 });
+ let Value::Object(settings) = json!({
+ "security.allowedUNCHosts": {
+ "type": "array",
+ "items": { "type": "string", "pattern": "^[^\\\\]+$", "patternErrorMessage": "UNC host names must not contain backslashes." },
+ "default": [],
+ "markdownDescription": "A set of UNC host names (without leading or trailing backslash, for example `192.168.0.1` or `my-server`) to allow without user confirmation. If a UNC host is being accessed that is not allowed via this setting or has not been acknowledged via user confirmation, an error will occur and the operation stopped. A restart is required when changing this setting. Find out more about this setting at https://aka.ms/vscode-windows-unc.",
+ "scope": 3,
+ "section": section,
+ "restricted": false,
+ },
+ "security.restrictUNCAccess": {
+ "type": "boolean",
+ "default": true,
+ "markdownDescription": "If enabled, only allows access to UNC host names that are allowed by the `#security.allowedUNCHosts#` setting or after user confirmation. Find out more about this setting at https://aka.ms/vscode-windows-unc.",
+ "scope": 3,
+ "section": section,
+ "restricted": false,
+ },
+ }) else {
+ unreachable!("an object literal")
+ };
+ settings
+}
+
/// `getDefaultValue(type)`.
fn js_truthy(value: &Value) -> bool {
match value {
@@ -541,6 +572,14 @@ fn default_for_type(type_: &Value) -> Value {
mod tests {
use super::*;
+ #[test]
+ fn the_unc_settings_are_registered_only_on_windows_and_restrict_by_default() {
+ let registry = Registry::with_extensions(&[]);
+ assert_eq!(registry.properties.contains_key("security.allowedUNCHosts"), cfg!(windows));
+ assert_eq!(windows_settings()["security.restrictUNCAccess"]["default"], json!(true));
+ assert_eq!(windows_settings()["security.allowedUNCHosts"]["default"], json!([]));
+ }
+
#[test]
fn the_folding_range_provider_setting_lists_the_extensions_with_code() {
let css = json!({ "name": "css-language-features", "displayName": "CSS", "description": "css", "main": "a", "categories": ["Programming Languages"] });
diff --git a/native/crates/files/src/disk.rs b/native/crates/files/src/disk.rs
index 24e6f53d356..d895682f450 100644
--- a/native/crates/files/src/disk.rs
+++ b/native/crates/files/src/disk.rs
@@ -32,8 +32,12 @@ pub(crate) fn io_error(err: std::io::Error, syscall: &str, path: &Path) -> crate
provider_error(name, format!("{code}: {text}, {syscall} '{}'", path.display()))
}
-fn path(resource: &Resource) -> &Path {
- Path::new(&resource.path)
+/// The resource's path, refused as diskFileSystemProvider.ts `toFileSystemProviderError` reports Node's
+/// `ERR_UNC_HOST_NOT_ALLOWED` when its UNC host is not allowed.
+fn path(resource: &Resource) -> Result<&Path> {
+ let path = Path::new(&resource.path);
+ crate::unc::check_unc_access(path).map_err(|err| provider_error(UNKNOWN, crate::unc::provider_message(&err)))?;
+ Ok(path)
}
/// `SymlinkSupport.stat`: follows a link and marks it; `ctime` is the birth time.
@@ -159,12 +163,12 @@ impl FileSystem for Disk {
}
fn stat(&mut self, resource: &Resource) -> Result<Stat> {
- stat_path(path(resource))
+ stat_path(path(resource)?)
}
/// Links report their target's type; entries that fail to stat are left out.
fn read_dir(&mut self, resource: &Resource) -> Result<Vec<(String, u32)>> {
- let folder = path(resource);
+ let folder = path(resource)?;
let entries = std::fs::read_dir(folder).map_err(|err| io_error(err, "scandir", folder))?;
let mut children = Vec::new();
for entry in entries.flatten() {
@@ -176,7 +180,7 @@ impl FileSystem for Disk {
/// `openFileForRead`: a folder or anything but a regular file is refused.
fn read_file(&mut self, resource: &Resource) -> Result<Vec<u8>> {
- let file = path(resource);
+ let file = path(resource)?;
let metadata = std::fs::metadata(file).map_err(|err| io_error(err, "open", file))?;
if metadata.is_dir() {
return Err(provider_error(FILE_IS_A_DIRECTORY, "File is a directory"));
@@ -188,19 +192,20 @@ impl FileSystem for Disk {
}
fn write_file(&mut self, resource: &Resource, content: &[u8], create: bool, overwrite: bool) -> Result<()> {
- let file = path(resource);
+ let file = path(resource)?;
validate_write(file, create, overwrite)?;
std::fs::write(file, content).map_err(|err| io_error(err, "open", file))
}
fn mkdir(&mut self, resource: &Resource) -> Result<()> {
- std::fs::create_dir(path(resource)).map_err(|err| io_error(err, "mkdir", path(resource)))
+ let folder = path(resource)?;
+ std::fs::create_dir(folder).map_err(|err| io_error(err, "mkdir", folder))
}
/// `use_trash` moves the item to the Trash as Electron's `shell.trashItem` (NSFileManager `trashItemAtURL`;
/// on Linux the freedesktop.org trash, as GIO's `g_file_trash` that Electron calls there).
fn delete(&mut self, resource: &Resource, recursive: bool, use_trash: bool) -> Result<()> {
- let target = path(resource);
+ let target = path(resource)?;
if use_trash {
#[cfg_attr(not(target_os = "macos"), allow(unused_mut))]
let mut context = trash::TrashContext::default();
@@ -218,7 +223,7 @@ impl FileSystem for Disk {
}
fn rename(&mut self, from: &Resource, to: &Resource, overwrite: bool) -> Result<()> {
- let (from, to) = (path(from), path(to));
+ let (from, to) = (path(from)?, path(to)?);
if from == to {
return Ok(());
}
@@ -227,7 +232,7 @@ impl FileSystem for Disk {
}
fn copy(&mut self, from: &Resource, to: &Resource, overwrite: bool) -> Result<()> {
- let (from, to) = (path(from), path(to));
+ let (from, to) = (path(from)?, path(to)?);
if from == to {
return Ok(());
}
diff --git a/native/crates/files/src/lib.rs b/native/crates/files/src/lib.rs
index 52408b87f99..77663202acd 100644
--- a/native/crates/files/src/lib.rs
+++ b/native/crates/files/src/lib.rs
@@ -6,6 +6,7 @@ pub mod disk;
pub mod encoding;
pub mod glob;
pub mod operations;
+pub mod unc;
pub mod user_data;
pub mod watcher;
diff --git a/native/crates/files/src/unc.rs b/native/crates/files/src/unc.rs
new file mode 100644
index 00000000000..464031c30e8
--- /dev/null
+++ b/native/crates/files/src/unc.rs
@@ -0,0 +1,101 @@
+//! base/node/unc.ts and the UNC host allowlist Electron's Node checks before each `fs` access on Windows
+//! (`ERR_UNC_HOST_NOT_ALLOWED`). The port has no patched `fs`: the file service, the text file models and
+//! webview resources call `check_unc_access` before they touch a path.
+
+use std::path::Path;
+use std::sync::Mutex;
+use std::sync::atomic::{AtomicBool, Ordering};
+
+static RESTRICTED: AtomicBool = AtomicBool::new(true);
+static ALLOWLIST: Mutex<Vec<String>> = Mutex::new(Vec::new());
+
+/// `getUNCHostAllowlist`.
+pub fn unc_host_allowlist() -> Vec<String> {
+ ALLOWLIST.lock().unwrap().clone()
+}
+
+/// `addUNCHostToAllowlist`: Windows only, lowercased (UNC hosts are case-insensitive).
+pub fn add_unc_host_to_allowlist(host: &str) {
+ if !cfg!(windows) {
+ return;
+ }
+ let host = host.to_lowercase();
+ let mut allowlist = ALLOWLIST.lock().unwrap();
+ if !allowlist.contains(&host) {
+ allowlist.push(host);
+ }
+}
+
+/// `addUNCHostToAllowlist` of the `security.allowedUNCHosts` value: its strings, other entries skipped.
+pub fn add_unc_hosts_to_allowlist(hosts: &serde_json::Value) {
+ for host in hosts.as_array().into_iter().flatten().filter_map(|host| host.as_str()) {
+ add_unc_host_to_allowlist(host);
+ }
+}
+
+/// `disableUNCAccessRestrictions`.
+pub fn disable_unc_access_restrictions() {
+ if cfg!(windows) {
+ RESTRICTED.store(false, Ordering::Relaxed);
+ }
+}
+
+/// `isUNCAccessRestrictionsDisabled`.
+pub fn is_unc_access_restrictions_disabled() -> bool {
+ !cfg!(windows) || !RESTRICTED.load(Ordering::Relaxed)
+}
+
+/// `getUNCHost`: the host of a `\\host\`, `\\?\UNC\host\` or `\\.\UNC\host\` path.
+pub fn unc_host(path: &str) -> Option<&str> {
+ for root in [r"\\.\UNC\", r"\\?\UNC\", r"\\"] {
+ let Some(rest) = path.strip_prefix(root) else { continue };
+ let Some(end) = rest.find('\\') else { continue };
+ if end > 0 {
+ return Some(&rest[..end]);
+ }
+ }
+ None
+}
+
+/// `isPathAllowedByUNCHostAllowlist`: not a UNC path, or one of an allowed host; a path that starts like a UNC path
+/// without a host it understands fails closed.
+pub fn is_path_allowed_by_unc_host_allowlist(path: &str, allowed_hosts: &[String]) -> bool {
+ if let Some(host) = unc_host(path) {
+ return allowed_hosts.iter().any(|allowed| allowed.to_lowercase() == host.to_lowercase());
+ }
+ !(path.starts_with(['\\', '/']) && path[1..].starts_with(['\\', '/']))
+}
+
+/// `isUNCAccessAllowed`.
+pub fn is_unc_access_allowed(path: &str) -> bool {
+ is_unc_access_restrictions_disabled() || unc_access_error(path, &unc_host_allowlist()).is_none()
+}
+
+/// The error Electron's `fs` throws for a path `is_unc_access_allowed` refuses.
+pub fn check_unc_access(path: &Path) -> std::io::Result<()> {
+ if is_unc_access_restrictions_disabled() {
+ return Ok(());
+ }
+ match unc_access_error(&path.to_string_lossy(), &unc_host_allowlist()) {
+ Some(message) => Err(std::io::Error::new(std::io::ErrorKind::PermissionDenied, message)),
+ None => Ok(()),
+ }
+}
+
+/// diskFileSystemProvider.ts `toFileSystemProviderError` of `ERR_UNC_HOST_NOT_ALLOWED`.
+pub fn provider_message(error: &std::io::Error) -> String {
+ format!("{error}. Please update the 'security.allowedUNCHosts' setting if you want to allow this host.")
+}
+
+/// Electron's `ERR_UNC_HOST_NOT_ALLOWED` message for a path its allowlist refuses. Node checks the namespaced path
+/// (`path.toNamespacedPath`), in which `/` is a separator, so `//host/share` is a UNC path too.
+pub fn unc_access_error(path: &str, allowed_hosts: &[String]) -> Option<String> {
+ let path = path.replace('/', "\\");
+ if is_path_allowed_by_unc_host_allowlist(&path, allowed_hosts) {
+ return None;
+ }
+ Some(format!("UNC host '{}' access is not allowed", unc_host(&path).unwrap_or_default()))
+}
+
+#[cfg(test)]
+mod tests;
diff --git a/native/crates/files/src/unc/tests.rs b/native/crates/files/src/unc/tests.rs
new file mode 100644
index 00000000000..4b777c653ea
--- /dev/null
+++ b/native/crates/files/src/unc/tests.rs
@@ -0,0 +1,62 @@
+use super::{is_path_allowed_by_unc_host_allowlist, unc_access_error, unc_host};
+
+/// base/test/node/unc.test.ts `getUNCHost`.
+#[test]
+fn get_unc_host() {
+ assert_eq!(unc_host("/"), None);
+ assert_eq!(unc_host("/foo"), None);
+ assert_eq!(unc_host("c:"), None);
+ assert_eq!(unc_host(r"c:\"), None);
+ assert_eq!(unc_host(r"c:\foo"), None);
+ assert_eq!(unc_host(r"c:\foo\\server\path"), None);
+ assert_eq!(unc_host(r"\"), None);
+ assert_eq!(unc_host(r"\\"), None);
+ assert_eq!(unc_host(r"\\localhost"), None);
+ assert_eq!(unc_host(r"\\localhost\"), Some("localhost"));
+ assert_eq!(unc_host(r"\\localhost\a"), Some("localhost"));
+ assert_eq!(unc_host(r"\\."), None);
+ assert_eq!(unc_host(r"\\?"), None);
+ assert_eq!(unc_host(r"\\.\localhost"), Some("."));
+ assert_eq!(unc_host(r"\\?\localhost"), Some("?"));
+ assert_eq!(unc_host(r"\\.\UNC\localhost"), Some("."));
+ assert_eq!(unc_host(r"\\?\UNC\localhost"), Some("?"));
+ assert_eq!(unc_host(r"\\.\UNC\localhost\"), Some("localhost"));
+ assert_eq!(unc_host(r"\\?\UNC\localhost\"), Some("localhost"));
+ assert_eq!(unc_host(r"\\.\UNC\localhost\a"), Some("localhost"));
+ assert_eq!(unc_host(r"\\?\UNC\localhost\a"), Some("localhost"));
+}
+
+/// base/test/node/unc.test.ts `isPathAllowedByUNCHostAllowlist`.
+#[test]
+fn is_path_allowed_by_unc_host_allowlist_matches_upstream() {
+ let allowed_hosts = ["allowed-host".to_owned()];
+ let cases = [
+ (r"\\allowed-host\share\a.png", true),
+ (r"\\ALLOWED-HOST\share\a.png", true),
+ (r"\\?\UNC\allowed-host\share\a.png", true),
+ (r"\\other-host\share\a.png", false),
+ (r"\\?\UNC\other-host\share\a.png", false),
+ (r"\\.\UNC\other-host\share\a.png", false),
+ (r"\\other-host.png", false),
+ ("//other-host/share/a.png", false),
+ (r"\\?\c:\foo\a.png", false),
+ (r"c:\foo\a.png", true),
+ (r"c:\foo\\other-host\a.png", true),
+ (r"\foo\a.png", true),
+ ("/foo/a.png", true),
+ ];
+ for (path, allowed) in cases {
+ assert_eq!(is_path_allowed_by_unc_host_allowlist(path, &allowed_hosts), allowed, "{path}");
+ }
+}
+
+#[test]
+fn the_access_error_names_the_host_and_takes_slashes_as_separators() {
+ let allowed_hosts = ["allowed-host".to_owned()];
+ assert_eq!(unc_access_error("//Allowed-Host/share/a.png", &allowed_hosts), None);
+ assert_eq!(unc_access_error("//other-host/share/a.png", &allowed_hosts).as_deref(), Some("UNC host 'other-host' access is not allowed"));
+ assert_eq!(unc_access_error(r"\\?\UNC\other-host\share", &allowed_hosts).as_deref(), Some("UNC host 'other-host' access is not allowed"));
+ assert_eq!(unc_access_error(r"\\.\pipe\x", &allowed_hosts).as_deref(), Some("UNC host '.' access is not allowed"));
+ assert_eq!(unc_access_error(r"c:\foo\a.png", &allowed_hosts), None);
+ assert_eq!(unc_access_error("/foo/a.png", &allowed_hosts), None);
+}
diff --git a/port/ledger.md b/port/ledger.md
index f5189433060..8f19be17f4d 100644
--- a/port/ledger.md
+++ b/port/ledger.md
@@ -83,7 +83,7 @@ Status: `open`, `in progress`, `waiting on Artur`, `later` (postponed), `done`,
| M24 Windows | app/src/keyboard_layout.rs:7 | open | [windows M] keyboard layout info and raw mapping (native-keymap's Windows `GetKeyboardLayout`, `MapVirtualKeyEx`, `ToUnicodeEx`). | `cargo gc test -p app keyboard` on the windows runner |
| M24 Windows | app/src/clipboard.rs:91 | open | [windows M] clipboard file lists, HTML and custom formats (Chromium's registered clipboard formats); GPUI's Windows clipboard has text and images. Windows shows now: text only. | `cargo gc test -p app clipboard` on the windows runner |
| M24 Windows | files/src/disk.rs:58 | open | [windows M] file system on NTFS: read-only through `FILE_ATTRIBUTE_READONLY`, file and directory symlinks, case-insensitive path compare, Recycle Bin (trash crate), ReadDirectoryChangesW (notify); Windows versions of the `cfg(unix)` tests that lock files or folders or make symlinks (readonly, text_files, explorer_actions, terminal completion_service). | `cargo gc test -p files` on the windows runner |
-| M24 Windows | app/src/editor_history.rs:59 | in progress | [windows L] drive-letter paths and file URIs (`file:///c%3A/...`, uri.ts `fsPath` on Windows, backslash separators in labels). Done: uri.rs `Uri::file` and `fs_path` as uri.ts `URI.file` and `uriToFsPath` (backslashes, drive letters, UNC authorities), used by editor_history.rs, the editor's model URIs (editor.rs `uri_value`, `uri_string`, host_requests.rs `uri_parts`, on Windows only: elsewhere a `//host` path keeps the port's form), backup_tracker.rs, file_dialogs.rs, language_features.rs and webview resources (`file_roots`, `is_contained` comparing `fsPath`s ignoring case as `extUri` on Windows, the WebView2 file read). Open: the other `file` URI reads (`uri["path"]` of a `file` URI taken as the path: debug, scm, search, notebooks, tasks and the rest), backslash separators in labels (labels.ts `getPathLabel`), and the UNC host check (`security.restrictUNCAccess`, `security.allowedUNCHosts`, Electron's node `ERR_UNC_HOST_NOT_ALLOWED`): a `file://host/share` URI now reaches `\\host\share`, so a link to it sends the user's NTLM credentials to that host. | `cargo gc test -p app uri::tests::file_uris_and_fs_paths_per_platform` and `cargo gc test -p app webview::tests::maps_resource_urls` on the host; [windows] api-tests and a webview image from the workspace on the windows runner |
+| M24 Windows | app/src/editor_history.rs:59 | in progress | [windows L] drive-letter paths and file URIs (`file:///c%3A/...`, uri.ts `fsPath` on Windows, backslash separators in labels). Done: uri.rs `Uri::file` and `fs_path` as uri.ts `URI.file` and `uriToFsPath` (backslashes, drive letters, UNC authorities), used by editor_history.rs, the editor's model URIs (editor.rs `uri_value`, `uri_string`, host_requests.rs `uri_parts`, on Windows only: elsewhere a `//host` path keeps the port's form), backup_tracker.rs, file_dialogs.rs, language_features.rs and webview resources (`file_roots`, `is_contained` comparing `fsPath`s ignoring case as `extUri` on Windows, the WebView2 file read). Open: the other `file` URI reads (`uri["path"]` of a `file` URI taken as the path: debug, scm, search, notebooks, tasks and the rest), backslash separators in labels (labels.ts `getPathLabel`). UNC host check (base/node/unc.ts, Electron's `ERR_UNC_HOST_NOT_ALLOWED`, `security.restrictUNCAccess` and `security.allowedUNCHosts` read at start as app.ts): done for the file service (disk.rs), the text file models, editor reads and webview resources (files/src/unc.rs); open: the reads that bypass these seams (terminal cwd, search, scm, debug, tasks, the extension host's own file access) and windowsMainService.ts `onUNCHostNotAllowed`, the Allow, Cancel, Learn More prompt for an opened path on a host not allowed (the port opens it and its reads fail with the setting's message). | `cargo gc test -p app uri::tests::file_uris_and_fs_paths_per_platform`, `cargo gc test -p app webview::tests::maps_resource_urls`, `cargo gc test -p files unc::tests` and `cargo gc test -p config the_unc_settings_are_registered_only_on_windows_and_restrict_by_default` on the host; [windows] api-tests and a webview image from the workspace on the windows runner |
| M24 Windows | app/src/settings_import.rs:28 | open | [windows S] settings import from `%APPDATA%\Code`, `%APPDATA%\Cursor`, `%APPDATA%\VSCodium`, extensions from `%USERPROFILE%\.vscode\extensions` and the others. | `cargo gc test -p app settings_import` on the windows runner |
| M24 Windows | app/src/workbench/shell_command.rs:70 | in progress | [windows S] no Shell Command on Windows (upstream has it on macOS only): the user setup puts `{app}\bin` on the user PATH (code.iss `addtopath`), the zip leaves PATH alone. | the commands absent from the palette on the windows runner; the installer row's check |
| M24 Windows | app/src/update/install.rs:21 | in progress | [windows M] updates as a download link, as on Linux (decision "Windows updates"). | `cargo gc test -p app update::` on the host |
diff --git a/port/notes.md b/port/notes.md
index 93b2f2ee00b..616bc9adc2c 100644
--- a/port/notes.md
+++ b/port/notes.md
@@ -1023,6 +1023,7 @@ What to do (milestone 21, in order):
- Console: the app is a GUI-subsystem binary, as Electron's, so a start from Explorer or the Start menu opens no console window; at start it attaches to the console of the process that started it unless the output is redirected or the CLI set `ELECTRON_NO_ATTACH_CONSOLE` (electron_main_win.cc, Chromium's `RouteStdioToConsole`), so `bin\<applicationName>.cmd --help` prints in the terminal.
- Proxy: `request/windows.rs` sends through curl.exe as Linux does, with the proxy picked first: the session proxy, else the IE settings, auto-detect and the PAC URL through WinHTTP's resolver where Chromium runs the script in its own V8 (same answer, other engine), then the manual proxy. The rule and bypass parsing is Chromium's (`request/proxy_rules.rs`, built on every platform for its host tests). Difference: curl takes one proxy, so a PAC list's later entries are no fallback. `WinHttpGetProxyForUrl` runs without `fAutoLogonIfChallenged` first and with it only after `ERROR_WINHTTP_LOGIN_FAILURE`, as Chromium's proxy_resolver_winhttp.cc, so the logon credentials go to a WPAD or PAC server only when it asks.
- File URIs: `uri.rs` `Uri::file` and `fs_path` are uri.ts `URI.file` and `uriToFsPath`, with the platform a parameter so the host tests check the Windows branches. The editor's model URIs take them on Windows only: elsewhere the port keeps a `//host/a` model path in the URI path (editor.rs `a_non_file_uri_keeps_its_authority`) where upstream makes `host` the authority.
+- UNC hosts: `files/src/unc.rs` is base/node/unc.ts with the allowlist Electron's Node checks on every `fs` call (`ERR_UNC_HOST_NOT_ALLOWED`). The port has no patched `fs`, so the check sits on its file seams: disk.rs `path` (the file service, with diskFileSystemProvider.ts's "Please update the 'security.allowedUNCHosts' setting" suffix), the text file models, editor reads and webview resources. Node checks the namespaced path, so `//host/share` counts as UNC and `\\.\` and `\\?\` paths without a host it understands fail closed. main.rs `configure_unc_access` reads `security.restrictUNCAccess` and `security.allowedUNCHosts` once at start as app.ts (a restart applies a change, as upstream's setting text says) and allows the extensions folder's host as main.ts `allowWindowsUNCPath`. The settings register on Windows only (workbench/common/configuration.ts). Not ported yet: windowsMainService.ts's Allow prompt for an opened path, and reads outside these seams (ledger row `app/src/editor_history.rs:59`).
- Keybindings: `keybindings.rs` `Os` is platform.ts `OperatingSystem`, `OS` the build's; labels, the Electron accelerator and contributed rules (`win`, `mac`, `linux` before `key`, keybindingService.ts `bindToCurrentPlatform`) take it as a parameter so the host tests check Windows. `default-win.json` is the reference's own Windows export ("Developer: Export Default Keybindings" with the platform forced, keybindingsExport.contribution.ts) turned into the port's table by `port/tools/default-keybindings`, which reproduces `default-macos.json` byte for byte from the macOS export; the weights come from the macOS rows. Linux keeps the macOS table until M23 adds `default-linux.json` in `default_table`. Windows has no keyboard mapper yet: labels are the US layout's.
- Menu bar and title bar: on Windows `workbench.rs` `title_bar` adds `menubar.rs` `custom_menubar` at the left and `window_controls` at the right, gated on `keybindings::OS`, so Linux (M23) turns it on by its `OS`. A title opens its `MenubarMainMenu` submenu as the workbench's context menu below it; `compact` opens one menu of the menus. The context keys `isMac`, `isMacNative`, `isWindows` and `isLinux` follow `OS` (`contextkey.rs` `constant_in`), which brings in upstream's Windows-only rows. Difference: Electron's title bar overlay draws the window controls with the system's glyphs; the port draws them with the codicon `chrome-*` glyphs and titlebarpart.css's `.window-icon` hover colors, and marks them with GPUI's `WindowControlArea`, so Windows hit-tests them as caption buttons (`HTMINBUTTON`, `HTMAXBUTTON` with snap layouts, `HTCLOSE`). The rest of the bar is `HTCAPTION`, hit-tested before any listener runs: the menu bar, the command center and the toolbar `occlude` it.