injection fix using shell=false#45740
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the local endpoints CLI invocation helper to mitigate command injection by avoiding shell=True + string-joined commands on non-Windows platforms, and introduces Windows-specific handling for commands that are provided as .cmd/.bat shims.
Changes:
- Switch non-Windows execution to
shell=Falsewith argv list. - Add Windows branch that builds a command line string via
subprocess.list2cmdline(...)and executes withshell=True. - Minor refactor/formatting around command printing and subprocess args construction.
You can also share your feedback on Copilot code review. Take the survey.
…into ayushhgarg/macos3
…into ayushhgarg/macos3
Member
Author
|
@microsoft-github-policy-service rerun |
Member
Author
|
@microsoft-github-policy-service agree |
…into ayushhgarg/macos3
…k/azure-sdk-for-python into ayushhgarg/macos3
achauhan-scc
approved these changes
Jun 17, 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.
Description
What
Fix command injection vulnerability (CWE-94) in
commandline_utility.pyby removingunsafe
shell=True+ string-join pattern.Related: MSRC Case 106104 (Moderate - Remote Code Execution)
Why
The
run_cli_commandfunction previously joined command arguments into a single stringvia
" ".join(cmd_arguments)and executed it withsubprocess.check_output(..., shell=True).This allowed shell metacharacters in user-controlled input (e.g.,
scoring_scriptpathin a deployment YAML) to break out of the command and execute arbitrary code.
Changes
shell=Falseand passcmd_argumentsas a list directly tosubprocess.check_outputon all platforms — shell metacharacters are never interpreted" ".join(cmd_arguments)pattern and the outdated commentreferencing the old
shell=Trueapproachrun_cli_commandcovering:shell,stderr,env);,&payloads matching MSRC attack vectors)CalledProcessErrorpropagationFix in local_endpoint_helper.py
OnlineEndpoints.list(local=True) crashed with json.JSONDecodeError when an endpoint cache file under ~/.azureml/inferencing was empty or partially written.
Guard the read loop in EndpointStub-backed list() to skip empty, partially-written, or unreadable cache files instead of raising.
Testing
&,;,|are passed asliteral strings and do not result in command injection