Repository navigation
Fix regional managed identity attestation endpoint selection by Azure cloud - #6238
Merged
Gladwin Johnson VR (gladjohn) merged 2 commits intoOct 27, 2026
Merged
Gladwin Johnson VR (gladjohn) merged 2 commits into
Gladwin Johnson VR (gladjohn) merged 2 commits into
Conversation
Resolve the attestation service from IMDS compute metadata on attested binding cache misses. Log and retain the platform endpoint for unavailable or unmapped cloud metadata, preserving cancellation and existing validation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 30f6db0b-e29c-474d-8fba-b560bd96f1bf
Contributor
There was a problem hiding this comment.
π’ Approval recommended
No active review issues are recorded for the cloud-specific KeyGuard endpoint selection change.
No open issues π
What changed in this PR
This PR updates managed identity v2 attestation in MSAL.NET to select the KeyGuard endpoint from IMDS Azure cloud metadata, while retaining the original endpoint when metadata is unavailable or unmapped.
Changes:
- Adds case-insensitive endpoint mappings for Azure Public, US Government, China, and Bleu clouds.
- Resolves the endpoint only when minting an attested binding, preserving cancellation and avoiding extra lookups for cached bindings or unattested requests.
- Adds mocked regression coverage for mappings, fallback, cancellation, and cached-token behavior.
Review limitation: base-branch provenance of the loaded review guidance was not verified.
| File | Description |
|---|---|
| tests/βMicrosoft.Identity.Test.Unit/βManagedIdentityTests/βImdsV2Tests.cs | Adds endpoint-selection tests and updates attestation request mocks. |
| src/βclient/βMicrosoft.Identity.Lab.Api/βHttp/βMockHelpers.cs | Adds configurable Azure environment metadata to mock responses. |
| src/βclient/βMicrosoft.Identity.Client/βManagedIdentity/βV2/βImdsV2ManagedIdentitySource.cs | Resolves the cloud-specific endpoint before invoking attestation. |
| src/βclient/βMicrosoft.Identity.Client/βManagedIdentity/βImdsComputeMetadataManager.cs | Maps cloud identifiers to endpoints with an original-endpoint fallback. |
| src/βclient/βMicrosoft.Identity.Client/βManagedIdentity/βComputeMetadataResponse.cs | Deserializes the IMDS azEnvironment field. |
Review effort: Balanced
Use location from the same compute metadata response for all mapped cloud endpoints. Preserve the existing unsupported-cloud fallback and verify regional endpoint delivery to the attestation provider. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 30f6db0b-e29c-474d-8fba-b560bd96f1bf
Neha Bhargava (neha-bhargava)
approved these changes
Oct 27, 2026
Gladwin Johnson VR (gladjohn)
enabled auto-merge (squash)
October 27, 2026 21:37
Robbie-Microsoft
approved these changes
Oct 27, 2026
Gladwin Johnson VR (gladjohn)
deleted the
gladjohn/fix-imds-attestation-cloud-endpoint
branch
October 27, 2026 22:16
This was referenced Oct 29, 2026
Closed
Merged
This was referenced Nov 12, 2026
Merged
maksii
pushed a commit
to maksii/paqvilo
that referenced
this pull request
Nov 16, 2026
Updated [Microsoft.Identity.Client](https://github.com/AzureAD/microsoft-authentication-library-for-dotnet) from 4.91.1 to 4.92.0. <details> <summary>Release notes</summary> _Sourced from [Microsoft.Identity.Client's releases](https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/releases)._ ## 4.92.0 ### New Features - Added `COSMIC_LOCATION` as a regional auto-detection source, after `REGION_NAME` and before IMDS. [#β6240](AzureAD/microsoft-authentication-library-for-dotnet#6240) - Added `ITokenCacheSnapshotProvider` and `TokenCacheSnapshot` for process-local token-cache capture and restore without repeated JSON serialization. Use V3 serialization for persistence. [#β6229](AzureAD/microsoft-authentication-library-for-dotnet#6229) ### Bug Fixes - Fixed certificate private-key attachment on .NET Framework 4.7.2 to support non-exportable CNG keys. [#β6244](AzureAD/microsoft-authentication-library-for-dotnet#6244) - Fixed managed identity KeyGuard attestation endpoint selection to use cloud-specific regional endpoints from IMDS compute metadata. [#β6238](AzureAD/microsoft-authentication-library-for-dotnet#6238) - Fixed Android broker request serialization by registering `BrokerRequest` in the source-generated JSON serializer context. [#β6226](AzureAD/microsoft-authentication-library-for-dotnet#6226) ### Changes - Updated `Microsoft.Identity.Client.NativeInterop` from 0.20.6 to 0.20.7. [#β6230](AzureAD/microsoft-authentication-library-for-dotnet#6230) - Reduced OpenTelemetry metric-tag allocations using `TagList` and cached canonical tag-key sets. Custom enrichers should use noncanonical tag names. [#β6227](AzureAD/microsoft-authentication-library-for-dotnet#6227) Commits viewable in [compare view](AzureAD/microsoft-authentication-library-for-dotnet@4.91.1...4.92.0). </details> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This was referenced Nov 16, 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.
Changes proposed in this request
Select the KeyGuard attestation service in MSAL Core using
azEnvironmentandlocationfrom the same IMDS response at/metadata/instance/compute?api-version=2021-02-01, rather than always using the endpoint supplied by/metadata/identity/getplatformmetadata.westus2.attestation.microsoft.com). The compute response supplieslocation; no missing-region fallback is added, and no second metadata request is needed.Compatibility and regression risk
Base behavior: Attestation receives the endpoint from CSR/platform metadata.
New behavior: Supported Azure clouds use the endpoints above. Other clouds retain the original endpoint. No public API or package dependency changes.
Affected scenarios: Attested managed identity v2 certificate minting, including PoP and bearer-over-mTLS flows. IMDSv1 capability discovery is unchanged.
PPE limitation:
azEnvironmentdoes not distinguish PPE/PPE-EAPv2 from production.AzurePublicCloudselects the production endpoint; this change adds no PPE override. Fallback applies only to unavailable/missing/unmapped cloud metadata, not to recognized public-cloud metadata.Testing
Added end-to-end mocked coverage for all four regional mappings, distinct public-cloud regions, case-insensitive matching, missing/unmapped cloud values, the original-endpoint fallback, unavailable/malformed compute metadata, cancellation, and cached-token behavior. Updated existing attestation mocks for the additional metadata request.
After the regional-prefix correction, all managed identity unit tests were rerun: 500 passed, 1 skipped, 0 failed on each of .NET Framework 4.8 and .NET 8.
Before the regional-prefix correction, the full unit suite passed, with
RunConfiguration.DisableAppDomain=truefor the local .NET Framework adapter:Other suites were attempted; these are not claimed as passing:
git diff --checkpasses. Formatting verification reports existing whitespace on unchanged lines; those unrelated lines were left intact.Performance impact
Adds an IMDS compute-metadata lookup when a new attested binding is minted, using the existing IMDS retry policy. No additional lookup on token/certificate-cache hits or requests without an attestation provider. No performance benchmark results claimed.
Documentation
Documentation edits are intentionally excluded from this PR.