fix: block WSL UNC paths in File System Access sensitive directory checks (#54676)

Port the upstream Chromium fix onto Electron's copy of MaybeIsLocalUNCPath()
so that `wsl.localhost` and `wsl.localhost.` UNC hosts are treated as local
(case-insensitive) and blocked like other local UNC paths.

Refs https://chromium-review.googlesource.com/c/chromium/src/+/8341352 (upstream commit bc5a321c6196db0a2de36f1fe3e4fab977b10007)


Claude-Session: https://claude.ai/code/session_018khRcY1YYaYT95VfQQiaGj

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
claude[bot]andClaude authored and GitHub committed 2026-10-07 16:59:37 +09:00
1 parent 699493a28f
commit 75d042de11
1 file changed
+6
@@ -121,6 +121,8 @@ constexpr base::TimeDelta kPermissionRevocationTimeout = base::Seconds(5);
});
}
// Returns true if the path is a Universal Naming Convention (UNC) path pointing
// to a local system path, device namespace, or WSL loopback redirector.
bool MaybeIsLocalUNCPath(const base::FilePath& path) {
if (!path.IsNetwork()) {
return false;
@@ -135,6 +137,10 @@ bool MaybeIsLocalUNCPath(const base::FilePath& path) {
if (components.size() >= 2 &&
(base::FilePath::CompareEqualIgnoreCase(components[1],
FILE_PATH_LITERAL("localhost")) ||
base::FilePath::CompareEqualIgnoreCase(
components[1], FILE_PATH_LITERAL("wsl.localhost")) ||
base::FilePath::CompareEqualIgnoreCase(
components[1], FILE_PATH_LITERAL("wsl.localhost.")) ||
components[1] == FILE_PATH_LITERAL("127.0.0.1") ||
components[1] == FILE_PATH_LITERAL(".") ||
components[1] == FILE_PATH_LITERAL("?") ||