Skip to content

Commit e33fae6

Browse files
anamnavipwshBot
authored andcommitted
Cherry-pick PR PowerShell#25943 with conflicts for manual resolution
1 parent 98f26c6 commit e33fae6

5 files changed

Lines changed: 18 additions & 0 deletions

File tree

src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1926,6 +1926,7 @@ protected override void BeginProcessing()
19261926
}
19271927
catch (CommandNotFoundException)
19281928
{
1929+
// codeql[cs/microsoft/command-line-injection-shell-execution] - This is expected Poweshell behavior where user inputted paths are supported for the context of this method. The user assumes trust for the file path they are specifying and the process is on the user's system except for remoting in which case restricted remoting security guidelines should be used.
19291930
startInfo.FileName = FilePath;
19301931
#if UNIX
19311932
// Arguments are passed incorrectly to the executable used for ShellExecute and not to filename https://github.com/dotnet/corefx/issues/30718

src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,6 +1296,20 @@ internal virtual HttpResponseMessage GetResponse(HttpClient client, HttpRequestM
12961296
_cancelToken = new CancellationTokenSource();
12971297
try
12981298
{
1299+
<<<<<<< HEAD
1300+
=======
1301+
if (IsWriteVerboseEnabled())
1302+
{
1303+
WriteWebRequestVerboseInfo(currentRequest);
1304+
}
1305+
1306+
if (IsWriteDebugEnabled())
1307+
{
1308+
WriteWebRequestDebugInfo(currentRequest);
1309+
}
1310+
1311+
// codeql[cs/ssrf] - This is expected Poweshell behavior where user inputted Uri is supported for the context of this method. The user assumes trust for the Uri and invocation is done on the user's machine, not a web application. If there is concern for remoting, they should use restricted remoting.
1312+
>>>>>>> 1e46d89c6 (Add Codeql Suppressions (#25943))
12991313
response = client.SendAsync(currentRequest, HttpCompletionOption.ResponseHeadersRead, _cancelToken.Token).GetAwaiter().GetResult();
13001314
}
13011315
catch (TaskCanceledException ex)

src/System.Management.Automation/engine/NativeCommandProcessor.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1397,6 +1397,7 @@ private ProcessStartInfo GetProcessStartInfo(
13971397
{
13981398
var startInfo = new ProcessStartInfo
13991399
{
1400+
// codeql[cs/microsoft/command-line-injection-shell-execution] - This is expected Poweshell behavior where user inputted paths are supported for the context of this method. The user assumes trust for the file path specified on the user's system to retrieve process info for, and in the case of remoting, restricted remoting security guidelines should be used.
14001401
FileName = this.Path
14011402
};
14021403

src/System.Management.Automation/engine/remoting/common/RunspaceConnectionInfo.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2230,6 +2230,7 @@ internal int StartSSHProcess(
22302230
// linux|macos:
22312231
// Subsystem powershell /usr/local/bin/pwsh -SSHServerMode -NoLogo -NoProfile
22322232

2233+
// codeql[cs/microsoft/command-line-injection-shell-execution] - This is expected Poweshell behavior where user inputted paths are supported for the context of this method. The user assumes trust for the file path specified, so any file executed in the runspace would be in the user's local system/process or a system they have access to in which case restricted remoting security guidelines should be used.
22332234
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(filePath);
22342235

22352236
// pass "-i identity_file" command line argument to ssh if KeyFilePath is set

src/System.Management.Automation/namespaces/FileSystemProvider.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,6 +1324,7 @@ protected override void InvokeDefaultAction(string path)
13241324
if (ShouldProcess(resource, action))
13251325
{
13261326
var invokeProcess = new System.Diagnostics.Process();
1327+
// codeql[cs/microsoft/command-line-injection-shell-execution] - This is expected Poweshell behavior where user inputted paths are supported for the context of this method. The user assumes trust for the file path they are specifying. If there is concern for remoting, restricted remoting guidelines should be used.
13271328
invokeProcess.StartInfo.FileName = path;
13281329
#if UNIX
13291330
bool useShellExecute = false;

0 commit comments

Comments
 (0)