Azure / Azure/azure-cli

'az keyvault role assignment' does not check for valid OIDs

Open
#25,990 6 comments 0 reactions 1 assignee Claimed by @evelyn-ys View on GitHub
act-identity-squad Auto-Assign Azure CLI Team customer-reported KeyVault question Service Attention
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

> ### `az feedback` auto-generates most of the information requested below, as of CLI version 2.0.62
The below command should validate the --assignee parameter before creating the role assignment.

**Related command**
az keyvault role assignment create --hsm-name "YourMHSM" --role 'Managed HSM Crypto User' --assignee 'application_object_id' --scope /keys/keyname

**Describe the bug**

In the above, we can specify any Application ID as assignee and the command will execute. This triggers an error when accessing the key's RBAC assignments in the portal. The portal bug is currently being investigated.

**To Reproduce**

1. Create a MHSM and a key.
2. In az cli, assign a role on the key (with scope /keys/keyname), and pick an application id instead.
3. In the portal, opening the above key RBAC details will trigger an error preventing the user from managing the key's RBAC.

**Expected behavior**

The command should not create a role assignment if given an invalid OID.
Following the docs, Application IDs should not be allowed: [Managed HSM role management
](https://learn.microsoft.com/en-us/azure/key-vault/managed-hsm/role-management)
"_To allow a security principal (such as **a user, a service principal, group or a managed identity**) to perform managed HSM data plane operations, they must be assigned a role that permits performing those operations._"

**Additional context**

![msedge_XOpNhXAr5h](https://user-images.githubusercontent.com/129375624/228778863-3d5b42cc-1289-4116-b6a5-b3a42c993d73.png)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.