Skip to content

[Bug] Key Vault Requests Fail After Re-Creating Key Vault in New Tenant #54231

@dockoneal

Description

@dockoneal

Library name and version

Azure.Identity 1.12.0, Azure.Security.KeyVault.Keys 4.6.0

Describe the bug

Azure.Security.KeyVault maintains a dictionary of key vault URIs to ChallengeParameters [1]. If a request has already been made to key vault, the challenge parameters determined by the SDK are stored in the cache and used for future requests. The tenant ID determined by the SDK is prioritized over the one provided by the caller [2].

The ChallengeParameter cache is never invalidated. If the key vault tenant ID changes due to subscription migration, then key vault requests will fail until the process restarts.

This behavior is affecting Ultra Disk storage. Customers cannot associate their key vault with a migrated disk due to this caching behavior. Restarting the service is not an ideal solution due to performance and availability SLAs.

[1]

private static readonly ConcurrentDictionary<string, ChallengeParameters> s_challengeCache = new();

[2] https://github.com/Azure/azure-sdk-for-net/blob/fca5abb395e85278232b81eeb04d256c55d62c06/sdk/identity/Azure.Identity/src/TenantIdResolver.cs#L40C17-L40C58

Expected behavior

Should be able to make key vault requests after creating a new key vault with the same name in a different tenant without restarting the application.

Actual behavior

Creating a key vault in a new tenant with the same name as the old tenant causes a conflict with the cached tenant ID making key vault requests impossible.

Reproduction Steps

  1. Have a key vault with a managed identity so you can make wrap/unwrap requests
  2. Delete the key vault and re-create the key vault with the same name in another tenant and create a new identity to access the key vault.
  3. Update the key vault, client ID, tenant ID, and credential without restarting your process
  4. Key vault requests fail

Environment

  • Microsoft Windows Server 2022 Datacenter 10.0.20348
  • .net framework 4.7.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    ClientThis issue is related to a non-management packageKeyVaultService AttentionWorkflow: This issue is responsible by Azure service team.customer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

    Type

    No type

    Projects

    Status

    Untriaged

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions