GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Validate remote module names before Import-Module by jshigetomi · Pull Request #28401 · PowerShell/PowerShell

Conversation

@jshigetomi

@jshigetomi Justin Chung (jshigetomi) commented Nov 11, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

PR Summary

PR Context

PR Checklist

  • PR has a meaningful title
  • Summarized changes
  • Existing files retain their copyright headers
  • This PR is ready to merge
  • Breaking changes
    • None
  • User-facing changes
    • Not Applicable
  • Testing - New and feature
    • N/A or can only be tested interactively

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Anam Navied Justin Chung
Sanitize remote module name used in ImportModuleCommand.cs (PowerShel…
d4df23c
…l#242)
@jshigetomi
Justin Chung (jshigetomi) requested a review from a team as a code owner November 11, 2026 19:12
Copilot AI balanced review requested due to automatic review settings November 11, 2026 19:12
@azure-pipelines

azure-pipelines Bot commented Nov 11, 2026

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Copilot started reviewing on behalf of Justin Chung (jshigetomi) November 11, 2026 19:16
View session
@jshigetomi Justin Chung (jshigetomi) added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label Nov 11, 2026
Copilot AI reviewed Nov 11, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new module-name validation lacks regression coverage for invalid names and platform-specific handling, leaving its error behavior and prevention of local proxy-file creation unverified.

1 open issue
  • Low severity Add regression tests for invalid module-name validation · New
What changed in this PR

Adds protective validation before Import-Module -PSSession uses remote module names to construct local proxy-module paths.

Changes:

  • Rejects null/empty names, path separators, ./.., and colons on Windows.
  • Reports an error and skips rejected modules before constructing local paths.
File Description
src/​System.Management.Automation/​resources/​Modules.resx Adds the error message for rejected module names.
src/​System.Management.Automation/​engine/​Modules/​ImportModuleCommand.cs Validates remote module names before local path construction.

Review effort: Balanced

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/System.Management.Automation/engine/Modules/ImportModuleCommand.cs
Version remoteModuleVersion,
PSSession psSession)
{
if (string.IsNullOrEmpty(remoteModuleName) || remoteModuleName.IndexOfAny(s_pathTraversalChars) >= 0 || remoteModuleName is "." or "..")
@jshigetomi Justin Chung (jshigetomi) changed the title Protect remote module import paths by validating module names Validate remote module names before Import-Module constructs local paths Nov 11, 2026
@jshigetomi Justin Chung (jshigetomi) changed the title Validate remote module names before Import-Module constructs local paths Validate remote module names before Import-Module Nov 11, 2026
@jshigetomi
Merge branch 'master' into 242bp
f81c490
iSazonov
Ilya (iSazonov) reviewed Nov 12, 2026
View reviewed changes
Comment thread src/System.Management.Automation/engine/Modules/ImportModuleCommand.cs
['\\', '/'];
#else
['\\', '/', ':'];
#endif

@iSazonov Ilya (iSazonov) Nov 12, 2026

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could use specific API like ContainsAny()
https://source.dot.net/#System.Private.CoreLib/src/runtime/src/libraries/System.Private.CoreLib/src/System/MemoryExtensions.cs,479

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

Reviewers

@iSazonov Ilya (iSazonov) iSazonov left review comments
Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments

At least 1 approving review is required to merge this pull request.

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@jshigetomi @iSazonov
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.