Skip to content

{Core} Fix injection risk during extension dynamic installation - #33990

Open
Ethan Yang (necusjz) wants to merge 1 commit into
Azure:devfrom
necusjz:fix-argument-injection
Open

{Core} Fix injection risk during extension dynamic installation#33990
Ethan Yang (necusjz) wants to merge 1 commit into
Azure:devfrom
necusjz:fix-argument-injection

Conversation

@necusjz

@necusjz Ethan Yang (necusjz) commented Aug 26, 2026

Copy link
Copy Markdown
Member

🤖 PR Validation — ️✔️ All clear

Breaking Changes Tests
️✔️ None ️✔️ 130/130

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:

from azure.cli.core.util import run_az_cmd
result = run_az_cmd(args[1:])
exit_code = getattr(result, 'exit_code', 0)

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 feature


This checklist is used to make sure that common guidelines for a pull request are followed.

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 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=...) to azure.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.

@yonzhan

Copy link
Copy Markdown
Collaborator

Core

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

Labels

act-platform-engineering-squad Auto-Assign Auto assign by bot Core CLI core infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants