Skip to content

XAML: constrain document-link targets to allowed roots #210

Open

Description

Follow-up from the PR #50 review (finding M1).

server/src/WinUiXaml.LanguageServer/XamlDocumentLinks.cs Combine() (lines 134-152) resolves a link target with Path.GetFullPath and then probes File.Exists, with no containment check against the workspace/project root. A crafted Source="C:\..." or a ..-heavy relative path in a XAML file therefore produces a clickable document link to an arbitrary local path.

Severity is limited because:

  • package.json declares untrustedWorkspaces: "limited", so the server does not run in untrusted workspaces.
  • The result is a link the user must click, not an automatic read of file contents.

The reason this was not fixed in PR #50: server/test/WinUiXaml.LanguageServer.Tests/XamlDocumentLinksTests.cs lines 265-272 explicitly asserts that an out-of-root absolute path such as C:\other\Colors.xaml resolves to a link. Tightening Combine() would break a blessed test, so this needs a product decision first.

Suggested work:

  • Decide whether absolute out-of-root link targets are intended (they are legitimate for some shared-resource-dictionary layouts).
  • If not, constrain resolution to the project/workspace roots and update XamlDocumentLinksTests.cs accordingly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions