Skip to content

Handle the new WSL filesystem path for the last Windows Build #17640

Closed

Description

Summary of the new feature / enhancement

The PR #13120 added a feature on Windows so that the paths of scripts hosted in WSL are recognized as in the computer security zone.

Over the last builds of WSL, paths have been added:

WSL Release Change (default in bold)

Initial 20175 21354
\\wsl$ \\wsl$ \\wsl$\
\\wsl \\wsl.localhost
  • WSL Build 20175 :

  • WSL Build 21354 :

    • Switch the \\wsl prefix to \\wsl.localhost to avoid issues when there is a machine on the network named "wsl".
    • \\wsl$ will continue to work.
      WSL/release-notes#build-21354

#13106 is came back depending on Windows version and channel.

Proposed technical implementation details (optional)

  • Append the path \\wsl.localhost to the computer security zone.

internal const string WslRootPath = @"\\wsl$";

  • Support both path :
# Execute a script inside the home Ubuntu-20.04
pwsh.exe -file '\\wsl$\Ubuntu-20.04\home\flavien\test.ps1'
pwsh.exe -file '\\wsl.localhost\Ubuntu-20.04\home\flavien\test.ps1'

Activity

  1. added
    Issue-Enhancement
    Needs-Triage
    on Jul 7, 2022
  2. iSazonov commented on Jul 7, 2022

    @iSazonov
    Collaborator

    The fix should be in

    string hostName = uri.Host;
    return hostName.Contains('.') ? SecurityZone.Internet : SecurityZone.Intranet;

    because Host is wsl.localhost

    Request Security group to approve.

  3. added
    WG-Security
    on Jul 7, 2022
  4. PaulHigin commented on Jul 18, 2022

    @PaulHigin
    Contributor

    @WG-Security
    Security working group feels the original change #13120 should be updated to support the new wsl path format along with the old. We feel the old format \\wsl$ is potentially problematic but that we need to continue providing support for down level versions. We understand that this is a defense-in-depth feature and we don't want to introduce a breaking change.

  5. added
    Up-for-Grabs
    and removed
    Needs-Triage
    on Jul 19, 2022
  6. fMichaleczek commented on Jul 19, 2022

    @fMichaleczek
    ContributorAuthor

    The fix should be in

    string hostName = uri.Host;
    return hostName.Contains('.') ? SecurityZone.Internet : SecurityZone.Intranet;

    because Host is wsl.localhost

    @iSazonov \\wsl$ is an uri and an Unc but written at the first line of the method, maybe because ReadFromZoneIdentifierDataStream (WSL is more trust than the download folder). I can update #13120 or rewrite the whole method, but that not the same job.

     internal const string[] WslRootPath =  new[] { @"\\wsl$"; @"\\wsl.localhost\" }; 
    
    if (filePath.StartsWith(Utils.WslRootPath[0], StringComparison.OrdinalIgnoreCase) || filePath.StartsWith(Utils.WslRootPath[1], StringComparison.OrdinalIgnoreCase) )
    

    * WslRootPath need contain an additional slash to deny \\wsl.localhost*

  7. iSazonov commented on Jul 19, 2022

    @iSazonov
    Collaborator

    Flavien MICHALECZEK (@fMichaleczek) Feel free to pull PR!

    One more question I have is should we address all URLs with .localhost suffix and return SecurityZone.MyComputer?

  8. microsoft-github-policy-service commented on Nov 15, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

  9. added
    Resolution-No Activity
    on Nov 15, 2023
  10. microsoft-github-policy-service commented on Nov 22, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.

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

    Issue-EnhancementResolution-No ActivityUp-for-GrabsWG-Security

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions