Skip to content

[ACR] az acr login: harden binary resolution and credential passing#33373

Open
lizMSFT wants to merge 1 commit into
Azure:devfrom
lizMSFT:zoeyli/acr/fix_docker_path_validation
Open

[ACR] az acr login: harden binary resolution and credential passing#33373
lizMSFT wants to merge 1 commit into
Azure:devfrom
lizMSFT:zoeyli/acr/fix_docker_path_validation

Conversation

@lizMSFT
Copy link
Copy Markdown
Member

@lizMSFT lizMSFT commented May 13, 2026

Related command
az acr login

Description
Harden Docker/Podman binary resolution and credential passing in az acr login:

  • Validate the resolved Docker/Podman binary path before invoking it
  • Switch credential passing from --password (command-line argument) to --password-stdin (stdin pipe)
  • Add DOCKER_COMMAND environment variable support for specifying a trusted absolute path to the binary
  • Refactor get_docker_command() into smaller helper functions for clarity
  • Add unit tests for the new path validation logic.

Testing Guide

# Normal login (should work as before)
az acr login -n <registry>

History Notes
[ACR] az acr login: Harden binary resolution and credential passing


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

Copilot AI review requested due to automatic review settings May 13, 2026 18:31
@azure-client-tools-bot-prd
Copy link
Copy Markdown

Validation for Azure CLI Full Test Starting...

Thanks for your contribution!

@azure-client-tools-bot-prd
Copy link
Copy Markdown

Validation for Breaking Change Starting...

Thanks for your contribution!

@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented May 13, 2026

Thank you for your contribution! We will review the pull request and get back to you soon.

@github-actions
Copy link
Copy Markdown

The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR.

Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions).
After that please run the following commands to enable git hooks:

pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Hardens az acr login by validating the resolved docker/podman binary path (rejecting binaries located directly in CWD) and switching credential passing from --password (CLI arg, visible in process listings) to --password-stdin (piped via stdin). The get_docker_command flow is also refactored into smaller helpers and a DOCKER_COMMAND env var is honored as a trusted absolute-path override.

Changes:

  • Switch _perform_registry_login to --password-stdin with BrokenPipeError/OSError handling and an updated wincred retry path.
  • Add _validate_command_path to refuse binaries resolved from CWD, with a diagnostics-mode soft path; integrate it into a new _resolve_docker_command helper plus _try_wsl_exe_fallback.
  • Add a unit test module covering CWD-block, system-path-allow, Windows-path, diagnostics, and symlink-bypass cases.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
src/azure-cli/azure/cli/command_modules/acr/custom.py Refactors get_docker_command, adds CWD path validation, switches docker login to --password-stdin.
src/azure-cli/azure/cli/command_modules/acr/tests/latest/test_acr_docker_path_validation.py New unit tests covering _validate_command_path behavior on POSIX, Windows, diagnostics, and symlink scenarios.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/azure-cli/azure/cli/command_modules/acr/custom.py
Comment thread src/azure-cli/azure/cli/command_modules/acr/custom.py
Comment thread src/azure-cli/azure/cli/command_modules/acr/custom.py
Comment thread src/azure-cli/azure/cli/command_modules/acr/custom.py
@lizMSFT lizMSFT force-pushed the zoeyli/acr/fix_docker_path_validation branch from dffabd8 to e1e8b72 Compare May 13, 2026 18:59
@lizMSFT lizMSFT changed the title [ACR] az acr login: harden binary resolution and switch to --password-stdin [ACR] az acr login: harden binary resolution and credential passing May 13, 2026
@lizMSFT lizMSFT force-pushed the zoeyli/acr/fix_docker_path_validation branch from e1e8b72 to 493af3a Compare May 15, 2026 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants