fix: move az login and account-set to admin-only access level#353
Merged
Conversation
mainred
approved these changes
Apr 15, 2026
gossion
added a commit
that referenced
this pull request
Apr 15, 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.
Summary
az loginandaz account setare moved fromreadwritetoadmin-only access levelreadwritemode, callingoperation=loginoroperation=account-setnow returns an errorBackground
MSRC report:
az loginwas exposed as areadwriteoperation. An attacker with MCP tool access (or via prompt injection) could calloperation=login, args="--service-principal --username X --password Y --tenant Z"to switch the system-level az CLI credential context to an attacker-controlled tenant. Unlike most defense-in-depth issues, this has persistent side effects — it writes to~/.azure/msal_token_cache.jsonand~/.azure/azureProfile.json, affecting all subsequent az CLI calls on the machine outside the MCP session.az account setis treated the same way: switching the active subscription is a system-state change that warrants admin-level gating.Changes
internal/components/azaks/registry.go: removedOpLoginandOpAccountSetfromreadWriteOps, added both toadminOps; updatedgenerateToolDescriptionto only listlogin/account-setat admin levelinternal/components/azaks/registry_test.go: added test cases verifyingloginandaccount-setare rejected atreadonlyandreadwrite, accepted atadminSeverity
Low (defense-in-depth). No privilege escalation — the attacker must supply their own service principal credentials. The harm is persistent disruption of the user's az CLI context. Does not warrant a CVE.
Test plan
go test ./internal/components/azaks/...— new access level test cases passgo test ./...— all 27 packages pass