Skip to content

Ban network paths wholesale - #64832

Merged
Jake Bailey (jakebailey) merged 10 commits into
microsoft:mainfrom
jakebailey:ban-network-paths
Oct 15, 2026
Merged

Jake Bailey (jakebailey) merged 10 commits into
microsoft:mainfrom
jakebailey:ban-network-paths

Conversation

@jakebailey

Copy link
Copy Markdown
Member

Simply trying to touch a network path may automatically send credentials over the network to a server. Just ban them entirely, across the board.

There are nice errors where possible, otherwise the funcs that hit the OS just reject them entirely.

Checking is cheap; max looking at the first 4 bytes of a path.

Opening a UNC or device path on Windows can make the OS connect to an
arbitrary SMB host and send the user's NTLM credentials. A malicious
tsconfig or import can supply such a path, so we need a single,
platform-independent way to recognize these paths in order to refuse
them.

Device paths and NT object paths (\??\) are included even when they
name local volumes, since their UNC and GLOBALROOT forms also reach
the network redirector, and tspath otherwise treats \??\ as a POSIX
rooted path.
Copilot AI balanced review requested due to automatic review settings October 15, 2026 17:56
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Oct 15, 2026
@typescript-automation typescript-automation Bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Oct 15, 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.

🔵 Needs a closer look

Unresolved correctness and network-access issues remain, and the security-sensitive Windows behavior requires human validation.

2 open findings
What changed in this PR

This PR adds network-path rejection across the native compiler’s filesystem, configuration parsing, and file watchers to prevent unintended network authentication.

Changes:

  • Adds a shared network-path detector and filesystem guards.
  • Reports unsupported paths in configuration and source references.
  • Adds regression tests and diagnostic baselines.
File Description
tsc/​testdata/​tests/​cases/​compiler/​networkPathReferences.ts Tests network-path references.
tsc/​testdata/​baselines/​reference/​config/​tsconfigParsing/​reports errors for network paths with jsonSourceFile api.js Records source-aware configuration diagnostics.
tsc/​testdata/​baselines/​reference/​config/​tsconfigParsing/​reports errors for network paths with json api.js Records JSON configuration diagnostics.
tsc/​testdata/​baselines/​reference/​compiler/​networkPathReferences.js Records emitted JavaScript.
tsc/​testdata/​baselines/​reference/​compiler/​networkPathReferences.errors.txt Records reference-path errors.
tsc/​internal/​vfs/​osvfs/​os.go Guards filesystem operations.
tsc/​internal/​vfs/​osvfs/​os_test.go Tests filesystem rejection.
tsc/​internal/​tsoptions/​tsconfigparsing.go Validates configuration paths.
tsc/​internal/​tsoptions/​tsconfigparsing_test.go Tests configuration diagnostics.
tsc/​internal/​project/​watch.go Filters network watcher paths.
tsc/​internal/​project/​watch_test.go Tests watcher filtering.
tsc/​internal/​nativepath/​network.go Defines network-path detection.
tsc/​internal/​nativepath/​network_test.go Tests path-prefix classification.
tsc/​internal/​fswatch/​watcher.go Rejects network watch requests.
tsc/​internal/​fswatch/​watcher_test.go Tests watch-request rejection.
tsc/​internal/​diagnostics/​diagnostics_generated.go Registers the generated diagnostic.
tsc/​internal/​diagnostics/​diagnosticMessages.json Defines the network-path diagnostic.
tsc/​internal/​diagnostics/​diagnosticMessages.generated.json Updates generated diagnostic text.
tsc/​internal/​compiler/​fileloader.go Rejects network source references.
Files not reviewed (1)
  • tsc/internal/diagnostics/diagnostics_generated.go: Generated file

🧠 Review effort: Balanced

Comment thread tsc/internal/tsoptions/tsconfigparsing.go
Comment thread tsc/internal/tsoptions/tsconfigparsing.go Outdated
The OS file system is the one place every compiler and language
service file access funnels through, so refusing network paths here
stops credential leaks regardless of which config option, import, or
editor request produced the path. Reads behave as if the path does not
exist, and writes fail.

Realpath also keeps the original path when a local path resolves to a
network location, such as a mapped network drive, so that following
accesses continue to use the path the user chose rather than becoming
inaccessible.
File watchers open the watched directory directly rather than going
through the OS file system, so they need their own check to avoid
connecting to a network host. Callers already only watch directories
that exist according to the file system, so this is a backstop.
Watch requests sent to the editor are performed by the client, outside
of our file system checks. Without filtering, a project referencing a
network location would make the editor itself connect to that host.
Network paths are now never accessed, so a tsconfig referring to one
would otherwise fail with confusing "file not found" errors or be
silently ignored. Report a dedicated error for network paths in
extends, file system path options, files, include, exclude, and
project references so it is clear why they are not used.
Like tsconfig paths, a reference path pointing at a network location
is never read; report why instead of claiming the file was not found.
Command-line options can come from response files, which may be
checked into a repository. Report network paths in path-valued options
there too, so they produce a clear error instead of reaching code that
writes to the file system directly, like the profiler.
Module resolution refuses to read network paths, so a network `paths`
substitution only produced an unhelpful resolution failure. Report it
where it is written in the config instead.

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.

🟡 Changes recommended

API and language-server profiling entry points still allow network filesystem access without the new guard.

1 open finding
2 resolved since last review
Files not reviewed (1)
  • tsc/internal/diagnostics/diagnostics_generated.go: Generated file

🧠 Review effort: Balanced

Comment thread tsc/internal/pprof/pprof.go Outdated
LSP and API clients can request CPU, heap, and allocation profiles
with an arbitrary directory, which previously went straight to the
OS and could trigger SMB authentication on Windows.

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.

🔵 Needs a closer look

Cross-platform credential-protection changes require human review and Windows-specific validation.

0 open findings

1 resolved since last review
Files not reviewed (1)
  • tsc/internal/diagnostics/diagnostics_generated.go: Generated file

🧠 Review effort: Balanced

The existing test only covered the array form of extends, so add
coverage for a plain string value and for one that only becomes a
network path after normalization.
@github-project-automation github-project-automation Bot moved this from Not started to Needs merge in PR Backlog Oct 15, 2026
@jakebailey
Jake Bailey (jakebailey) added this pull request to the merge queue Oct 15, 2026
Merged via the queue into microsoft:main with commit ce30dd5 Oct 15, 2026
29 checks passed
@jakebailey
Jake Bailey (jakebailey) deleted the ban-network-paths branch October 15, 2026 21:09
@github-project-automation github-project-automation Bot moved this from Needs merge to Done in PR Backlog Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants