{Core} Fix injection risk during extension dynamic installation - #33990
Open
Ethan Yang (necusjz) wants to merge 1 commit into
Open
{Core} Fix injection risk during extension dynamic installation#33990Ethan Yang (necusjz) wants to merge 1 commit into
Ethan Yang (necusjz) wants to merge 1 commit into
Conversation
microsoft-github-policy-service
Bot
requested a review
from Yong Zhang (yonzhan)
August 26, 2026 04:18
Contributor
There was a problem hiding this comment.
Pull request overview
This PR removes a command-injection risk in extension dynamic installation by replacing the Windows subprocess.call(..., shell=True) rerun path with the CLI’s in-process run_az_cmd rerun path (args remain a list; no shell involvement). It also adds a targeted unit test to assert the rerun is performed via run_az_cmd and that exit-code propagation remains consistent.
Changes:
- Replace post-install rerun implementation in dynamic extension install from
subprocess.call(..., shell=...)toazure.cli.core.util.run_az_cmd(args[1:]). - Preserve prior UX/telemetry intent by suppressing duplicate error printing when the rerun path is enabled.
- Add a unit test ensuring rerun uses list args (no shell reinterpretation) and returns the rerun’s exit code.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/azure-cli-core/azure/cli/core/extension/dynamic_install.py | Replaces subprocess-based rerun (shell on Windows) with run_az_cmd to eliminate shell injection risk while keeping exit-code behavior. |
| src/azure-cli-core/azure/cli/core/tests/test_parser.py | Adds a regression test validating the rerun uses run_az_cmd with list args and does not emit duplicate error output. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Collaborator
|
Core |
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 Validation — ️✔️ All clear
Related command
Description
Fixed by rerunning through the CLI's centralized run_az_cmd (per doc/cli_subprocess_guidelines.md), which keeps args as a list and involves no shell:
Exit code propagation and existing telemetry/error-message behavior are unchanged. The command is now rerun in-process instead of in a child process; user-visible output is the same.
Testing Guide
History Notes
[Component Name 1] BREAKING CHANGE:
az command a: Make some customer-facing breaking change[Component Name 2]
az command b: Add some customer-facing featureThis checklist is used to make sure that common guidelines for a pull request are followed.
The PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.
I adhere to the Error Handling Guidelines.