Skip to content

Validates package root URIs - #10096

Open
johnpryan wants to merge 3 commits into
masterfrom
harden-dtd-workspace-roots
Open

johnpryan wants to merge 3 commits into
masterfrom
harden-dtd-workspace-roots

Conversation

@johnpryan

@johnpryan johnpryan commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

This change validates the detected directory in VmServiceHandler before caching it or updating DTD, requiring that it:

  • Is a local file:// URI with no authority, query, fragment, or dot-segment traversal (. / ..)
  • Does not point or resolve (via symlinks) to the filesystem root or the user's home directory (HOME / USERPROFILE), and exists on disk
  • Contains either pubspec.yaml or .dart_tool/package_config.json.

It also extracts shared isValidLocalFileUri and isValidLocalFileUriString helpers in file_utils.dart (reused by ExtensionsManager and the extensions API handler) and adds unit and server API tests covering valid roots, invalid URI forms, filesystem/home root rejection, missing package markers, and end-to-end /api/notifyForVmServiceConnection handling.

Makes progress towards:

This change validates the detected directory in VmServiceHandler before caching
it or updating DTD, requiring that it:

is a local file:// URI with no authority, query, fragment, or dot-segment
traversal (. / ..), does not point or resolve (via symlinks) to the filesystem
root or the user's home directory (HOME / USERPROFILE), and exists on disk and
contains either pubspec.yaml or .dart_tool/package_config.json.

It also extracts shared isValidLocalFileUri and isValidLocalFileUriString
helpers in file_utils.dart (reused by ExtensionsManager and the extensions API
handler) and adds unit and server API tests covering valid roots, invalid URI
forms, filesystem/home root rejection, missing package markers, and end-to-end
/api/notifyForVmServiceConnection handling.

Makes progress towards:
* flutter/dash-devexp-internal#88
* flutter/dash-devexp-internal#93

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request introduces package root validation in VmServiceHandler before caching or updating Dart Tooling Daemon (DTD) workspace roots, utilizing new local file URI validation helpers to prevent path traversal and reject invalid roots (such as the filesystem root or user home directory). The review feedback highlights a critical logical issue where validating the package root during disconnect flows can prevent proper cleanup of DTD workspace roots if the directory or its package markers were deleted during the session. It is recommended to skip validation when connected is false to ensure stale roots are successfully removed.

@johnpryan
johnpryan requested a review from a team as a code owner November 18, 2026 23:30
@johnpryan
johnpryan requested review from srawlins and removed request for a team November 18, 2026 23:30

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant