Repository navigation
Apply implicit-remoting command protections to resolved aliases - #28208
Merged
Merged
Conversation
|
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.
🟡 Changes recommended
The corrected resolved-name safety check needs a regression test for an alias targeting an unsafe command name.
1 open finding
What changed in this PR
This PR applies implicit-remoting import safeguards to alias targets, preventing aliases from bypassing command restrictions.
Changes:
- Validates resolved command names for safety.
- Applies server skip-list and local clobber checks to alias targets.
- Adds tests for restrictions and prefix-based imports.
| File | Description |
|---|---|
| test/powershell/Modules/Microsoft.PowerShell.Utility/Implicit.Remoting.Tests.ps1 | Adds alias restriction tests and updates clobber handling. |
| src/Microsoft.PowerShell.Commands.Utility/commands/utility/ImplicitRemotingCommands.cs | Applies import safeguards to resolved alias targets. |
🧠 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)) |
| } | ||
|
|
||
| if (resolvedCommandName != null && !IsSafeNameOrIdentifier(commandMetadata.Name)) | ||
| if (resolvedCommandName is not null && !IsSafeNameOrIdentifier(resolvedCommandName)) |
Collaborator
There was a problem hiding this comment.
Before the change IsSafeNameOrIdentifier was used only once and it threw if null or empty.
Now we always check for not null so we could do the check in IsSafeNameOrIdentifier.
Also here we don't check for empty but do the check below.
Should we move both checks to IsSafeNameOrIdentifier?
12 tasks
Dongbo Wang (daxian-dbw)
approved these changes
Oct 16, 2026
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 improves the handling of command aliases and skip-list checks during implicit remoting in PowerShell, ensuring that commands on the server's skip-list cannot be imported via aliases unless explicitly allowed. It also adds new tests to cover these scenarios.
PR Context
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright header