Repository navigation
Fix the shadowing command bypass via alias for Import/Export-PSSession - #28217
Open
Aditya Patwardhan (adityapatwardhan) wants to merge 1 commit into
Open
Aditya Patwardhan (adityapatwardhan) wants to merge 1 commit into
Aditya Patwardhan (adityapatwardhan) wants to merge 1 commit into
Conversation
Aditya Patwardhan (adityapatwardhan)
requested a review
from a team
as a code owner
October 14, 2026 23:08
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
Static review found no blocking issues; the remaining regression-test suggestion is non-blocking, and tests were not executed.
1 open finding
What changed in this PR
This PR strengthens implicit remoting by applying import restrictions to alias targets.
Changes:
- Validates resolved alias names and prevents unintended command shadowing.
- Applies server skip-list checks to alias targets when no prefix is supplied.
- Adds alias regression tests and updates an existing test to allow clobbering explicitly.
| File | Description |
|---|---|
| test/powershell/Modules/Microsoft.PowerShell.Utility/Implicit.Remoting.Tests.ps1 | Tests alias restrictions and prefixed imports. |
| src/Microsoft.PowerShell.Commands.Utility/commands/utility/ImplicitRemotingCommands.cs | Checks resolved alias targets before import. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
| } | ||
|
|
||
| if (resolvedCommandName != null && !IsSafeNameOrIdentifier(commandMetadata.Name)) | ||
| if (resolvedCommandName is not null && !IsSafeNameOrIdentifier(resolvedCommandName)) |
Collaborator
|
Duplicates #28208 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

PR Summary
This pull request enhances the behavior and test coverage of implicit remoting in PowerShell, specifically focusing on how command aliases and server-side skip-lists are handled during
Import-PSSession. The main code changes refine the logic to prevent bypassing server-side restrictions via aliases, and the tests are expanded to validate these scenarios, including cases with and without command name prefixes.Key improvements to command import logic:
AddRemoteCommandMetadata(inImplicitRemotingCommands.cs) to:Enhanced test coverage for alias and skip-list scenarios:
Implicit.Remoting.Tests.ps1to verify:-AllowClobber.AllowClobberparameter, ensuring the test accurately reflects scenarios where command clobbering is permitted.PR Context
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright header