Skip to content

Call CodeGeneration.EscapeSingleQuotedStringContent API in SyncCurrentLocationHandler - #27874

Merged
Travis Plunk (TravisEz13) merged 1 commit into
PowerShell:masterfrom
anamnavi:wincompat-validation
Aug 20, 2026
Merged

Travis Plunk (TravisEz13) merged 1 commit into
PowerShell:masterfrom
anamnavi:wincompat-validation

Conversation

@anamnavi

@anamnavi Anam Navied (anamnavi) commented Aug 20, 2026

Copy link
Copy Markdown
Member

PR Summary

This pull request improves location synchronization in Windows Compatibility scenarios by updating how Set-Location commands are generated and invoked. Paths are now formatted more reliably when constructing the command, and the Set-Location cmdlet is fully qualified to ensure consistent command resolution.

PR Context

PR Checklist

@anamnavi
Anam Navied (anamnavi) requested a review from a team as a code owner August 20, 2026 18:35
Copilot AI lite review requested due to automatic review settings August 20, 2026 18:35
@azure-pipelines

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This pull request updates the Windows Compatibility location-sync logic (SyncCurrentLocationHandler) to generate a more robust Set-Location invocation when updating the compat remoting session’s working directory.

Changes:

  • Escapes the location string using CodeGeneration.EscapeSingleQuotedStringContent before embedding it in a single-quoted PowerShell string.
  • Fully qualifies the cmdlet as Microsoft.PowerShell.Management\Set-Location to avoid command name ambiguity.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/System.Management.Automation/engine/Modules/ModuleCmdletBase.cs
@anamnavi Anam Navied (anamnavi) added the CL-Engine Indicates that a PR should be marked as an engine change in the Change Log label Aug 20, 2026
@TravisEz13
Travis Plunk (TravisEz13) enabled auto-merge (squash) August 20, 2026 21:00
@TravisEz13
Travis Plunk (TravisEz13) merged commit 9299036 into PowerShell:master Aug 20, 2026
44 of 48 checks passed
@Ataago-Blueoptima

Copy link
Copy Markdown

@copilot This change escapes args.NewPath.Path with CodeGeneration.EscapeSingleQuotedStringContent before it's interpolated into the Set-Location -Path '...' script text. Before this fix, a path containing a single quote could break out of the string literal and inject arbitrary PowerShell that would execute in the WinCompat helper session. Can you confirm this PR fixes that injection (CWE-917), and whether the Microsoft.PowerShell.Management\Set-Location qualification is also closing a command-hijacking angle (e.g. a user-defined Set-Location function/alias shadowing the cmdlet)?

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

Labels

CL-Engine Indicates that a PR should be marked as an engine change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants