Skip to content

[AKS] az aks check-acr: Validate --acr is a valid host name and mount host paths read-only - #34361

Merged
mansoor sarfraz (msarfraz) merged 2 commits into
Azure:devfrom
fseldow:xinhl/check-acr-hardening
Nov 5, 2026
Merged

mansoor sarfraz (msarfraz) merged 2 commits into
Azure:devfrom
fseldow:xinhl/check-acr-hardening

Conversation

@fseldow

@fseldow Xinhe Li (fseldow) commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

🤖 PR Validation — ️✔️ All clear

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

Related command
az aks check-acr

Description
Defense-in-depth hardening for az aks check-acr:

  • --acr must now be a valid DNS host name (A-Z a-z 0-9 - labels separated by ., max 253 chars). Otherwise the command fails with InvalidArgumentValueError. The check does not assume any suffix, so custom domains and sovereign cloud login servers still work. The existing suffix-append behavior is unchanged.
  • The host paths mounted into the canipull pod (/etc/kubernetes, /etc/ssl/certs, /etc/pki) are now mounted readOnly. canipull only reads these files.

Testing Guide

  • Added unit tests in acs/tests/latest/test_validators.py (TestValidateRegistryName) for valid host names and rejected values (quotes/brackets, leading -, --config=..., empty labels, trailing dot, whitespace/newline, port, >253 chars).
  • pytest acs/tests/latest/test_validators.py acs/tests/latest/test_custom.py: all tests related to this change pass. The only failures are 8 install_kubelogin / install_desktop tests, which fail the same way on the unmodified base in my local environment.
az aks check-acr -g MyResourceGroup -n MyManagedCluster --acr myacr.azurecr.io     # works as before
az aks check-acr -g MyResourceGroup -n MyManagedCluster --acr "bad acr"            # InvalidArgumentValueError

History Notes
[AKS] az aks check-acr: Validate --acr is a valid host name and mount host paths read-only in the check pod


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

… host paths read-only

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Xinhe Li <xinhl@microsoft.com>
@microsoft-github-policy-service microsoft-github-policy-service Bot added the customer-reported Issues that are reported by GitHub users external to the Azure organization. label Nov 5, 2026
@microsoft-github-policy-service

Copy link
Copy Markdown
Contributor

Thank you for your contribution Xinhe Li (@fseldow)! We will review the pull request and get back to you soon.

@microsoft-github-policy-service microsoft-github-policy-service Bot added Auto-Assign Auto assign by bot AKS az aks/acs/openshift act-observability-squad labels Nov 5, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Xinhe Li <xinhl@microsoft.com>
@fseldow
Xinhe Li (fseldow) marked this pull request as ready for review November 5, 2026 02:58
Copilot AI balanced review requested due to automatic review settings November 5, 2026 02:58

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.

🟢 Approval recommended

No active review issues are recorded for the registry host-name validation and read-only host-mount changes.

No open issues 🎉

What changed in this PR

This PR hardens az aks check-acr by validating registry host names and restricting the diagnostic pod’s access to host files.

Changes:

  • Rejects invalid --acr host names while preserving existing suffix-append behavior.
  • Makes all three host-path mounts in the canipull pod read-only.
  • Adds unit tests for accepted host names and malformed inputs.
File Description
src/​azure-cli/​azure/​cli/​command_modules/​acs/​tests/​latest/​test_validators.py Adds valid and invalid registry host-name test cases.
src/​azure-cli/​azure/​cli/​command_modules/​acs/​custom.py Marks the diagnostic pod’s host-path mounts read-only.
src/​azure-cli/​azure/​cli/​command_modules/​acs/​_validators.py Adds host-name validation and rejects invalid --acr values.

Review effort: Balanced

@x-engineering-agent

Copy link
Copy Markdown
Contributor

Hi Xinhe Li (@fseldow),
Since the current milestone time is less than 7 days, this pr will be reviewed in the next milestone.

@yonzhan

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

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.

LGTM

@msarfraz
mansoor sarfraz (msarfraz) merged commit 1dd7524 into Azure:dev Nov 5, 2026
52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

act-observability-squad AKS az aks/acs/openshift Auto-Assign Auto assign by bot customer-reported Issues that are reported by GitHub users external to the Azure organization.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants