Repository navigation
Add MSAL_MI_DISABLE_IMDS_V2 kill switch for managed identity - #6178
Conversation
Adds an environment-variable kill switch that disables IMDSv2 as an emergency mitigation. IMDSv2 remains enabled by default; the switch is honored only for the values "true" or "1" (case-insensitive ordinal), and any other value is a no-op so a typo cannot silently degrade a fleet. The variable is read live on every check, so it takes effect and can be reversed without restarting the process. Behavior while the switch is set: - Plain bearer requests fall back to IMDSv1 and keep working. - WithMtlsProofOfPossession and WithRequestOverMtls fail fast with the new MsalError.ImdsV2Disabled rather than silently downgrading to an unbound token the caller did not ask for. This matches what MSAL already does on hosts that genuinely lack IMDSv2 support. - GetManagedIdentityCapabilitiesAsync reports MaxSupportedBindingStrength None with a populated ErrorReason, so credential chains such as DefaultAzureCredential select the bearer path instead of a PoP path that is guaranteed to fail. This is a behavior change on a public API; the signature is unchanged. The switch is enforced at three points rather than once at startup, because MSAL caches both the discovery result (in a process-wide static) and the binding certificate. A discovery-only check would be bypassed by any process that was already warm when the switch was flipped, which is exactly the situation during an incident. The discovery cache is masked on read and is not written while the switch is set. Masking stops a process that cached IMDSv2 beforehand from continuing to advertise PoP; not caching stops a switch-induced "v1-only" result from outliving the mitigation and requiring a restart to recover. Together these keep the switch reversible in place in both directions. Adds 22 unit tests covering value parsing, both cache-bypass paths, the warm certificate cache, bearer fallback, and reversibility. Each gate was verified to be load-bearing by disabling it and confirming the expected tests failed. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Declining to cache a switch-influenced discovery result kept the mitigation reversible but made it expensive: Azure.Identity calls GetManagedIdentityCapabilitiesAsync on every authentication and caches nothing itself, so every token request would have paid a serialized IMDS round trip for the duration of an incident. Record the switch state alongside the cached result instead. Off-to-on is masked on read, so no re-probe. Only on-to-off discards the cache, because that result never probed IMDSv2 and describes the switch rather than the host. Discovery is now O(1) in both modes and still reversible in place. Also: - Warn once per process when the variable is set to an unrecognized value. - Document the ErrorReason contract: non-null does not imply unavailability. - Correct the docs on error-code precedence, add the net462/net472 note, and document that already-cached tokens are not revoked. - Add regression tests for repeated discovery, the all-sources-unavailable verdict, and the token-cache carve-out. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
The new cached-state tracking introduces a potential inconsistent read/write concurrency hazard, and the capabilities masking can omit the kill-switch reason in ErrorReason for cached IMDSv1/None results.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds an emergency, process-wide environment-variable kill switch (MSAL_MI_DISABLE_IMDS_V2) to disable IMDSv2 managed identity behavior at runtime (without redeploying), while preserving IMDSv1 bearer-token availability and introducing a dedicated error code (MsalError.ImdsV2Disabled) for IMDSv2-required requests.
Changes:
- Introduces
MSAL_MI_DISABLE_IMDS_V2parsing + “unrecognized value” warning, and enforces the switch across discovery, routing, and mTLS-binding entry points. - Adds a new public error code (
MsalError.ImdsV2Disabled) with corresponding error message and PublicAPI entries across TFMs. - Adds a comprehensive unit-test suite covering parsing, cache poisoning in both directions, fallback behavior, and warm-cache bypass prevention; adds SDK guidance + dedicated docs page.
File summaries
| File | Description |
|---|---|
| tests/Microsoft.Identity.Test.Unit/ManagedIdentityTests/ImdsV2Tests.cs | Adds unit coverage for kill-switch parsing, routing/discovery interactions, and cache-bypass regressions. |
| src/client/Microsoft.Identity.Client/PublicApi/netstandard2.0/PublicAPI.Unshipped.txt | Declares new public error-code constant in API baseline. |
| src/client/Microsoft.Identity.Client/PublicApi/net8.0/PublicAPI.Unshipped.txt | Declares new public error-code constant in API baseline. |
| src/client/Microsoft.Identity.Client/PublicApi/net8.0-ios/PublicAPI.Unshipped.txt | Declares new public error-code constant in API baseline. |
| src/client/Microsoft.Identity.Client/PublicApi/net8.0-android/PublicAPI.Unshipped.txt | Declares new public error-code constant in API baseline. |
| src/client/Microsoft.Identity.Client/PublicApi/net472/PublicAPI.Unshipped.txt | Declares new public error-code constant in API baseline. |
| src/client/Microsoft.Identity.Client/PublicApi/net462/PublicAPI.Unshipped.txt | Declares new public error-code constant in API baseline. |
| src/client/Microsoft.Identity.Client/MsalErrorMessage.cs | Adds user-facing error strings for IMDSv2-disabled request failures and discovery diagnostics. |
| src/client/Microsoft.Identity.Client/MsalError.cs | Adds new public error-code constant + XML documentation describing mitigation and contrast with host capability limits. |
| src/client/Microsoft.Identity.Client/ManagedIdentity/ManagedIdentityClient.cs | Implements the kill switch across discovery caching, request routing, and mTLS binding acquisition. |
| src/client/Microsoft.Identity.Client/ManagedIdentity/ManagedIdentityCapabilities.cs | Updates ErrorReason doc semantics to cover “reduced capability” scenarios (not only total failure). |
| src/client/Microsoft.Identity.Client/ManagedIdentity/EnvironmentVariables.cs | Adds kill-switch env-var name constant, parsing, and “unrecognized value” detection. |
| docs/msi_v2/imds_v2_kill_switch.md | Documents accepted values, runtime behavior, enforcement points, logging, and testing. |
| docs/msi_v2/guidance_for_sdks_consuming_msal.md | Adds guidance for SDKs that branch on managed identity capabilities in the presence of the kill switch. |
Review details
Suppressed comments (1)
src/client/Microsoft.Identity.Client/ManagedIdentity/ManagedIdentityClient.cs:361
ApplyImdsV2KillSwitchreturns early for cached IMDSv1 +Noneresults, which meansManagedIdentityCapabilities.ErrorReasoncan fail to mention that the kill switch is active (e.g., if the process previously cached an IMDSv1-only discovery result and thenMSAL_MI_DISABLE_IMDS_V2is set). This is inconsistent with the documented behavior thatErrorReasonshould explain the reduced capability while the switch is on.
if (!imdsV2Disabled ||
result.Source != ManagedIdentitySource.Imds ||
(result.DetectedImdsVersion != ImdsVersion.V2 &&
result.MaxSupportedBindingStrength == MtlsBindingStrength.None))
{
- Files reviewed: 14/14 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Conflicts were limited to the six PublicAPI.Unshipped.txt files, where both sides added entries: main added the ICloudConfiguration surface (#6104) and this branch added MsalError.ImdsV2Disabled. Resolved by keeping both sides and restoring the analyzer's ordering (types, then const, then static, each alphabetical). Verified with a clean build on net462, net472, net8.0, and netstandard2.0. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The result and the switch state it was computed under lived in two separate static fields, written and read outside the discovery lock. A reader could observe a fresh result paired with a stale flag, or the reverse, and then misjudge whether the cached value describes the host or merely describes the switch. The two readers also used opposite orderings, which made the pair harder to reason about than it needed to be. Collapse both into an immutable CachedDiscovery snapshot published and read through a single volatile reference, so the pair is untearable by construction rather than by argument. Behavior is unchanged. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
There are a couple of concrete behavior/robustness issues (unrecognized-value warning not emitted on token-only flows, and inconsistent double-reading of the env var) that should be fixed to match the stated contract.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 14/14 changed files
- Comments generated: 2
- Review effort level: Lite
…y path Read the kill switch environment variable once per check instead of twice. IsImdsV2Disabled and HasUnrecognizedImdsV2DisableValue each issued their own Environment.GetEnvironmentVariable call, so a caller reading both observed two separate reads that could disagree if the variable changed in between. Both now derive from a single read via a shared private classifier. Emit the unrecognized-value warning from SelectManagedIdentitySourceType as well. It previously fired only from GetManagedIdentityCapabilitiesAsync, so a process that only acquires bearer tokens never ran discovery and never saw the warning - which is the worst case, because a bearer-only process is exactly what is running when IMDSv2 has been disabled in response to an incident. Still logged once per process through the existing Interlocked guard. Add a regression test covering the bearer-only path. It fails when the new call site is removed. Correct the kill switch documentation. The Purpose section asserted an operator persona and a rollout motivation that the originating issue does not state. Rewritten to describe only the specified behavior, with the design reasoning kept but explicitly labeled as inference rather than a stated requirement. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🔵 Needs a closer look
It introduces security-critical runtime gating and caching behavior in managed identity flows, and should receive final human validation despite only minor actionable review notes.
Review details
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
src/client/Microsoft.Identity.Client/ManagedIdentity/ManagedIdentityClient.cs:278
- The comments here still refer to
s_cachedSourceResult, but that field was removed and replaced withs_cachedDiscovery. Leaving the old name is misleading when debugging kill-switch routing behavior.
- Files reviewed: 14/14 changed files
- Comments generated: 1
- Review effort level: Lite
Comments across the kill switch change spent too many lines narrating mechanics the code already states. Trimmed to lead with the reason a given decision was made and dropped the restatements. Fix a doc comment defect introduced when EnvironmentVariables was refactored to share a single environment read: the summary belonging to IsImdsV2Disabled was left stranded above ReadImdsV2DisableState, giving that method two stacked summary blocks and leaving IsImdsV2Disabled undocumented. Correct two comments and one doc paragraph that still referred to s_cachedSourceResult, a field renamed to s_cachedDiscovery when the cached result and switch state were collapsed into one snapshot. Remove framing the originating task (#6174) does not state. The issue specifies the variable, its accepted values, and the required behavior; it does not describe who sets it or the circumstances under which they would. Wording that asserted an operator persona, an incident, or an emergency mitigation has been replaced with what the switch does and why the design follows. The design rationale that remains in the documentation is still labeled as inference. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
The kill-switch state is read multiple times per request path, which can produce inconsistent decisions or misleading warnings when the environment variable is flipped at runtime.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
Suppressed comments (2)
src/client/Microsoft.Identity.Client/ManagedIdentity/ManagedIdentityClient.cs:209
- SelectManagedIdentitySourceType reads MSAL_MI_DISABLE_IMDS_V2 twice (IsImdsV2Disabled, then WarnOnceIfImdsV2DisableValueUnrecognized -> HasUnrecognizedImdsV2DisableValue). If an operator flips the variable between those reads (a supported scenario per the PR design), the warning can become misleading (e.g., logging that IMDSv2 remains enabled while routing has already observed it as disabled). Read and classify the variable once per routing decision, and only attempt the warning when that same snapshot says the value is unrecognized.
bool imdsV2Disabled = EnvironmentVariables.IsImdsV2Disabled;
// Warned here too, because a process that only acquires bearer tokens never runs
// capability discovery and would otherwise never learn its switch value is inert.
WarnOnceIfImdsV2DisableValueUnrecognized(requestContext);
src/client/Microsoft.Identity.Client/ManagedIdentity/ManagedIdentityClient.cs:405
- GetManagedIdentityCapabilitiesAsync also reads MSAL_MI_DISABLE_IMDS_V2 twice (IsImdsV2Disabled, then WarnOnceIfImdsV2DisableValueUnrecognized). Because the kill switch is explicitly live/read-per-check, the variable can change mid-call and produce inconsistent behavior or misleading logging. Use a single read/classification for both the cached-result selection and the unrecognized-value warning in this method.
bool imdsV2Disabled = EnvironmentVariables.IsImdsV2Disabled;
WarnOnceIfImdsV2DisableValueUnrecognized(requestContext);
- Files reviewed: 14/14 changed files
- Comments generated: 1
- Review effort level: Lite
SelectManagedIdentitySourceType and GetManagedIdentityCapabilitiesAsync each read the environment variable twice: once through IsImdsV2Disabled to decide the request, and again inside WarnOnceIfImdsV2DisableValueUnrecognized to decide whether to warn. The switch is deliberately read live so it stays reversible without a restart, so those two reads can straddle a change. The two states are mutually exclusive, so only one interleaving misbehaves: a value changed from "true" to an unrecognized value between the reads blocks the request off the first read while logging "IMDSv2 remains enabled" off the second. Enforcement stays correct either way - the first read governs routing, the downgrade, and the throw for the whole method, so the switch cannot fail open - but the log can contradict the request it describes. Promote the classifier to internal and pass the classification into the warning instead of re-reading, so each request path reads once and the warning can only ever describe the read that decided the request. This mirrors the treatment already applied to the cached discovery result and its switch state, which were collapsed into a single snapshot for the same reason. Remove HasUnrecognizedImdsV2DisableValue, which has no remaining callers and was the API that made the double read possible. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🔵 Needs a closer look
The kill-switch masking logic can fail to reflect the disabled state for previously cached IMDSv1-only discovery results, and the new doc incorrectly describes net472 behavior.
Review details
Suppressed comments (2)
Previously missed (2) — in code that hasn't changed since the last review.
src/client/Microsoft.Identity.Client/ManagedIdentity/ManagedIdentityClient.cs:387
- ApplyImdsV2KillSwitch returns the cached discovery result unchanged when it is already (IMDSv1 + MaxSupportedBindingStrength=None). If the host was discovered as IMDSv1-only before MSAL_MI_DISABLE_IMDS_V2 was set, this short-circuit prevents the kill switch from being reflected in the discovery result (e.g., ErrorReason/ImdsV2FailureReason won’t indicate the switch is on). This contradicts the documented/expected “switch takes precedence” diagnostics while disabled.
docs/msi_v2/imds_v2_kill_switch.md:81 - The note about framework support is inaccurate: ManagedIdentityPopExtensions gates these APIs only under
#if NET462, not net472. Also, “throw … at build time” is misleading—on net462 the code compiles but throws when the method is invoked. The doc should reflect the actual conditional behavior so consumers don’t incorrectly assume net472 is excluded.
- Files reviewed: 14/14 changed files
- Comments generated: 0 new
- Review effort level: Lite
Gladwin Johnson VR (gladjohn)
left a comment
There was a problem hiding this comment.
This PR substantially exceeds the task. Existing IMDSv1 behavior already rejects PoP requests. Please implement only the environment-variable check that disables IMDSv2 discovery/routing, preserve the existing IMDSv1 bearer and PoP behavior, and document that restart/recycle is required.
MSAL reads the process environment, which is fixed when the process starts, so the switch cannot change mid-process outside tests. The earlier version carried state and cache handling for transitions that cannot occur in a real host. Enforcement is now two checks. Discovery skips the IMDSv2 probe and reports no binding support. Source selection stops the direct-to-IMDSv2 route by converting an early return into a fall-through, so mTLS requests reach the IMDSv1 guard that already rejects them. An mTLS request does not always run discovery: with no minimum strength floor the binding path skips the capability call entirely, so a check placed only in discovery leaves that route minting bound tokens. Removes the dedicated error code, the unrecognized-value warning, and the reverse-direction cache change. No public API surface changes. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Updated [Microsoft.Extensions.Configuration](https://github.com/dotnet/dotnet) from 10.0.11 to 10.0.13. <details> <summary>Release notes</summary> _Sourced from [Microsoft.Extensions.Configuration's releases](https://github.com/dotnet/dotnet/releases)._ No release notes found for this version range. Commits viewable in [compare view](https://github.com/dotnet/dotnet/commits). </details> Updated [Microsoft.Extensions.Configuration.Abstractions](https://github.com/dotnet/dotnet) from 10.0.11 to 10.0.13. <details> <summary>Release notes</summary> _Sourced from [Microsoft.Extensions.Configuration.Abstractions's releases](https://github.com/dotnet/dotnet/releases)._ No release notes found for this version range. Commits viewable in [compare view](https://github.com/dotnet/dotnet/commits). </details> Updated [Microsoft.Extensions.Configuration.Binder](https://github.com/dotnet/dotnet) from 10.0.11 to 10.0.13. <details> <summary>Release notes</summary> _Sourced from [Microsoft.Extensions.Configuration.Binder's releases](https://github.com/dotnet/dotnet/releases)._ No release notes found for this version range. Commits viewable in [compare view](https://github.com/dotnet/dotnet/commits). </details> Updated [Microsoft.Extensions.Configuration.EnvironmentVariables](https://github.com/dotnet/dotnet) from 10.0.11 to 10.0.13. <details> <summary>Release notes</summary> _Sourced from [Microsoft.Extensions.Configuration.EnvironmentVariables's releases](https://github.com/dotnet/dotnet/releases)._ No release notes found for this version range. Commits viewable in [compare view](https://github.com/dotnet/dotnet/commits). </details> Updated [Microsoft.Extensions.Configuration.Json](https://github.com/dotnet/dotnet) from 10.0.11 to 10.0.13. <details> <summary>Release notes</summary> _Sourced from [Microsoft.Extensions.Configuration.Json's releases](https://github.com/dotnet/dotnet/releases)._ No release notes found for this version range. Commits viewable in [compare view](https://github.com/dotnet/dotnet/commits). </details> Updated [Microsoft.Extensions.Configuration.UserSecrets](https://github.com/dotnet/dotnet) from 10.0.11 to 10.0.13. <details> <summary>Release notes</summary> _Sourced from [Microsoft.Extensions.Configuration.UserSecrets's releases](https://github.com/dotnet/dotnet/releases)._ No release notes found for this version range. Commits viewable in [compare view](https://github.com/dotnet/dotnet/commits). </details> Updated [Microsoft.Extensions.Logging.Abstractions](https://github.com/dotnet/dotnet) from 10.0.11 to 10.0.13. <details> <summary>Release notes</summary> _Sourced from [Microsoft.Extensions.Logging.Abstractions's releases](https://github.com/dotnet/dotnet/releases)._ No release notes found for this version range. Commits viewable in [compare view](https://github.com/dotnet/dotnet/commits). </details> Updated [Microsoft.Identity.Client](https://github.com/AzureAD/microsoft-authentication-library-for-dotnet) from 4.88.0 to 4.91.0. <details> <summary>Release notes</summary> _Sourced from [Microsoft.Identity.Client's releases](https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/releases)._ ## 4.91.0 ### New Features - Made the dynamic certificate provider and confidential-client callbacks (`OnMsalServiceFailure`, `OnCompletion`, and `OnBackgroundTokenRefreshCompleted`) generally available, removing the experimental feature opt-in requirement. [#6216](AzureAD/microsoft-authentication-library-for-dotnet#6216) ### Bug Fixes - Fixed built-in mTLS `HttpClient` caching to use certificate object identity, ensuring a new certificate instance with a reacquired private-key handle receives a new handler even when its thumbprint is unchanged. [#6217](AzureAD/microsoft-authentication-library-for-dotnet#6217) - Fixed managed identity `WithForceRefresh(true)` to re-mint the MSI v2 binding certificate before acquiring a new token, while reusing a valid cached attestation token for the current key. [#6215](AzureAD/microsoft-authentication-library-for-dotnet#6215) - Fixed system-browser authentication callbacks in Linux containers by adding opt-in IPv4 port-forwarding support through `MSAL_ALLOW_SYSTEM_BROWSER_PORT_FORWARDING`, disabled by default. [#6186](AzureAD/microsoft-authentication-library-for-dotnet#6186) ## 4.90.1 ### New Features - Added `IMsalWsTrustHttpClientFactory`, allowing custom HTTP client factories to provide redirect-disabled, credential-policy-aware clients for federation metadata (MEX) and WS-Trust requests. Added `MsalError.TooManyRedirects` and `MsalError.WsTrustCrossOriginRedirectNotSupported` for redirect failures. [#6165](AzureAD/microsoft-authentication-library-for-dotnet#6165) ### Bug Fixes - Hardened federation metadata and WS-Trust requests by requiring HTTPS, securely validating redirects, rejecting credential-bearing cross-origin redirects, and limiting redirect chains. [#6165](AzureAD/microsoft-authentication-library-for-dotnet#6165) - Fixed instance discovery so a custom authority port is not forwarded to the global discovery host, while preserving the port when discovery uses the authority host. [#6155](AzureAD/microsoft-authentication-library-for-dotnet#6155) - Fixed KeyGuard attestation to send the tenant ID as the MAA `client_id` metadata value without changing managed-identity client-ID handling or attestation-cache partitioning. [#6200](AzureAD/microsoft-authentication-library-for-dotnet#6200) ### Changes - Updated `Microsoft.Azure.Security.KeyGuardAttestation` from version 1.1.7 to 1.1.8. [#6202](AzureAD/microsoft-authentication-library-for-dotnet#6202) ## 4.90.0 ### Changes - Updated the KeyGuardAttestation package version to 1.1.7. [#6189](AzureAD/microsoft-authentication-library-for-dotnet#6189) ## 4.89.0 ## What's Changed * Add repository guidance for AI agents by @bgavrilMS in AzureAD/microsoft-authentication-library-for-dotnet#6158 * Add Linux Attested Managed Identity Flow documentation by @gladjohn in AzureAD/microsoft-authentication-library-for-dotnet#6149 * Remove internal authority example from API docs by @bgavrilMS in AzureAD/microsoft-authentication-library-for-dotnet#6170 * Update SNI MTLS PoP Token Design documentation by @bgavrilMS in AzureAD/microsoft-authentication-library-for-dotnet#6171 * Add SNI mTLS E2E coverage for a non-exportable VBS-protected certificate by @gladjohn in AzureAD/microsoft-authentication-library-for-dotnet#6167 * Revise mTLS PoP acceptance-test matrix structure by @gladjohn in AzureAD/microsoft-authentication-library-for-dotnet#6161 * Add ICloudConfiguration for cross-cloud metadata resolution by @Avery-Dunn in AzureAD/microsoft-authentication-library-for-dotnet#6104 * Fix IMDSv2 SCHANNEL failures bypassing certificate re-mint retry by @Robbie-Microsoft in AzureAD/microsoft-authentication-library-for-dotnet#6173 * Always record RawStsErrorCode on MsalFailure metric by @ssmelov in AzureAD/microsoft-authentication-library-for-dotnet#6175 * Add MSAL_MI_DISABLE_IMDS_V2 kill switch for managed identity by @Robbie-Microsoft in AzureAD/microsoft-authentication-library-for-dotnet#6178 * Add timeout for managed identity capability discovery by @Robbie-Microsoft in AzureAD/microsoft-authentication-library-for-dotnet#6181 * Pin GitHub Actions to full-length commit SHAs by @danfiedler-msft in AzureAD/microsoft-authentication-library-for-dotnet#6182 ## New Contributors * @danfiedler-msft made their first contribution in AzureAD/microsoft-authentication-library-for-dotnet#6182 **Full Changelog**: AzureAD/microsoft-authentication-library-for-dotnet@4.88.0...4.89.0 Commits viewable in [compare view](AzureAD/microsoft-authentication-library-for-dotnet@4.88.0...4.91.0). </details> Updated [Microsoft.Identity.Client.Extensions.Msal](https://github.com/AzureAD/microsoft-authentication-library-for-dotnet) from 4.88.0 to 4.91.0. <details> <summary>Release notes</summary> _Sourced from [Microsoft.Identity.Client.Extensions.Msal's releases](https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/releases)._ ## 4.91.0 ### New Features - Made the dynamic certificate provider and confidential-client callbacks (`OnMsalServiceFailure`, `OnCompletion`, and `OnBackgroundTokenRefreshCompleted`) generally available, removing the experimental feature opt-in requirement. [#6216](AzureAD/microsoft-authentication-library-for-dotnet#6216) ### Bug Fixes - Fixed built-in mTLS `HttpClient` caching to use certificate object identity, ensuring a new certificate instance with a reacquired private-key handle receives a new handler even when its thumbprint is unchanged. [#6217](AzureAD/microsoft-authentication-library-for-dotnet#6217) - Fixed managed identity `WithForceRefresh(true)` to re-mint the MSI v2 binding certificate before acquiring a new token, while reusing a valid cached attestation token for the current key. [#6215](AzureAD/microsoft-authentication-library-for-dotnet#6215) - Fixed system-browser authentication callbacks in Linux containers by adding opt-in IPv4 port-forwarding support through `MSAL_ALLOW_SYSTEM_BROWSER_PORT_FORWARDING`, disabled by default. [#6186](AzureAD/microsoft-authentication-library-for-dotnet#6186) ## 4.90.1 ### New Features - Added `IMsalWsTrustHttpClientFactory`, allowing custom HTTP client factories to provide redirect-disabled, credential-policy-aware clients for federation metadata (MEX) and WS-Trust requests. Added `MsalError.TooManyRedirects` and `MsalError.WsTrustCrossOriginRedirectNotSupported` for redirect failures. [#6165](AzureAD/microsoft-authentication-library-for-dotnet#6165) ### Bug Fixes - Hardened federation metadata and WS-Trust requests by requiring HTTPS, securely validating redirects, rejecting credential-bearing cross-origin redirects, and limiting redirect chains. [#6165](AzureAD/microsoft-authentication-library-for-dotnet#6165) - Fixed instance discovery so a custom authority port is not forwarded to the global discovery host, while preserving the port when discovery uses the authority host. [#6155](AzureAD/microsoft-authentication-library-for-dotnet#6155) - Fixed KeyGuard attestation to send the tenant ID as the MAA `client_id` metadata value without changing managed-identity client-ID handling or attestation-cache partitioning. [#6200](AzureAD/microsoft-authentication-library-for-dotnet#6200) ### Changes - Updated `Microsoft.Azure.Security.KeyGuardAttestation` from version 1.1.7 to 1.1.8. [#6202](AzureAD/microsoft-authentication-library-for-dotnet#6202) ## 4.90.0 ### Changes - Updated the KeyGuardAttestation package version to 1.1.7. [#6189](AzureAD/microsoft-authentication-library-for-dotnet#6189) ## 4.89.0 ## What's Changed * Add repository guidance for AI agents by @bgavrilMS in AzureAD/microsoft-authentication-library-for-dotnet#6158 * Add Linux Attested Managed Identity Flow documentation by @gladjohn in AzureAD/microsoft-authentication-library-for-dotnet#6149 * Remove internal authority example from API docs by @bgavrilMS in AzureAD/microsoft-authentication-library-for-dotnet#6170 * Update SNI MTLS PoP Token Design documentation by @bgavrilMS in AzureAD/microsoft-authentication-library-for-dotnet#6171 * Add SNI mTLS E2E coverage for a non-exportable VBS-protected certificate by @gladjohn in AzureAD/microsoft-authentication-library-for-dotnet#6167 * Revise mTLS PoP acceptance-test matrix structure by @gladjohn in AzureAD/microsoft-authentication-library-for-dotnet#6161 * Add ICloudConfiguration for cross-cloud metadata resolution by @Avery-Dunn in AzureAD/microsoft-authentication-library-for-dotnet#6104 * Fix IMDSv2 SCHANNEL failures bypassing certificate re-mint retry by @Robbie-Microsoft in AzureAD/microsoft-authentication-library-for-dotnet#6173 * Always record RawStsErrorCode on MsalFailure metric by @ssmelov in AzureAD/microsoft-authentication-library-for-dotnet#6175 * Add MSAL_MI_DISABLE_IMDS_V2 kill switch for managed identity by @Robbie-Microsoft in AzureAD/microsoft-authentication-library-for-dotnet#6178 * Add timeout for managed identity capability discovery by @Robbie-Microsoft in AzureAD/microsoft-authentication-library-for-dotnet#6181 * Pin GitHub Actions to full-length commit SHAs by @danfiedler-msft in AzureAD/microsoft-authentication-library-for-dotnet#6182 ## New Contributors * @danfiedler-msft made their first contribution in AzureAD/microsoft-authentication-library-for-dotnet#6182 **Full Changelog**: AzureAD/microsoft-authentication-library-for-dotnet@4.88.0...4.89.0 Commits viewable in [compare view](AzureAD/microsoft-authentication-library-for-dotnet@4.88.0...4.91.0). </details> Updated [Microsoft.Kiota.Abstractions](https://github.com/microsoft/kiota-dotnet) from 2.1.1 to 2.1.2. <details> <summary>Release notes</summary> _Sourced from [Microsoft.Kiota.Abstractions's releases](https://github.com/microsoft/kiota-dotnet/releases)._ ## 2.1.2 ## [2.1.2](microsoft/kiota-dotnet@v2.1.1...v2.1.2) (2026-09-08) ### Bug Fixes * **serialization-json:** honor custom TimeSpan converters ([#795](microsoft/kiota-dotnet#795)) ([e22c5ba](microsoft/kiota-dotnet@e22c5ba)) * **serialization-json:** honor DateTimeOffset converters ([802e20a](microsoft/kiota-dotnet@802e20a)) * **serialization-json:** honor guid converters before fallback parsing ([#794](microsoft/kiota-dotnet#794)) ([22cc1d3](microsoft/kiota-dotnet@22cc1d3)) Commits viewable in [compare view](microsoft/kiota-dotnet@v2.1.1...v2.1.2). </details> Updated [Microsoft.Kiota.Http.HttpClientLibrary](https://github.com/microsoft/kiota-dotnet) from 2.1.1 to 2.1.2. <details> <summary>Release notes</summary> _Sourced from [Microsoft.Kiota.Http.HttpClientLibrary's releases](https://github.com/microsoft/kiota-dotnet/releases)._ ## 2.1.2 ## [2.1.2](microsoft/kiota-dotnet@v2.1.1...v2.1.2) (2026-09-08) ### Bug Fixes * **serialization-json:** honor custom TimeSpan converters ([#795](microsoft/kiota-dotnet#795)) ([e22c5ba](microsoft/kiota-dotnet@e22c5ba)) * **serialization-json:** honor DateTimeOffset converters ([802e20a](microsoft/kiota-dotnet@802e20a)) * **serialization-json:** honor guid converters before fallback parsing ([#794](microsoft/kiota-dotnet#794)) ([22cc1d3](microsoft/kiota-dotnet@22cc1d3)) Commits viewable in [compare view](microsoft/kiota-dotnet@v2.1.1...v2.1.2). </details> Updated [Microsoft.Kiota.Serialization.Form](https://github.com/microsoft/kiota-dotnet) from 2.1.1 to 2.1.2. <details> <summary>Release notes</summary> _Sourced from [Microsoft.Kiota.Serialization.Form's releases](https://github.com/microsoft/kiota-dotnet/releases)._ ## 2.1.2 ## [2.1.2](microsoft/kiota-dotnet@v2.1.1...v2.1.2) (2026-09-08) ### Bug Fixes * **serialization-json:** honor custom TimeSpan converters ([#795](microsoft/kiota-dotnet#795)) ([e22c5ba](microsoft/kiota-dotnet@e22c5ba)) * **serialization-json:** honor DateTimeOffset converters ([802e20a](microsoft/kiota-dotnet@802e20a)) * **serialization-json:** honor guid converters before fallback parsing ([#794](microsoft/kiota-dotnet#794)) ([22cc1d3](microsoft/kiota-dotnet@22cc1d3)) Commits viewable in [compare view](microsoft/kiota-dotnet@v2.1.1...v2.1.2). </details> Updated [Microsoft.Kiota.Serialization.Json](https://github.com/microsoft/kiota-dotnet) from 2.1.1 to 2.1.2. <details> <summary>Release notes</summary> _Sourced from [Microsoft.Kiota.Serialization.Json's releases](https://github.com/microsoft/kiota-dotnet/releases)._ ## 2.1.2 ## [2.1.2](microsoft/kiota-dotnet@v2.1.1...v2.1.2) (2026-09-08) ### Bug Fixes * **serialization-json:** honor custom TimeSpan converters ([#795](microsoft/kiota-dotnet#795)) ([e22c5ba](microsoft/kiota-dotnet@e22c5ba)) * **serialization-json:** honor DateTimeOffset converters ([802e20a](microsoft/kiota-dotnet@802e20a)) * **serialization-json:** honor guid converters before fallback parsing ([#794](microsoft/kiota-dotnet#794)) ([22cc1d3](microsoft/kiota-dotnet@22cc1d3)) Commits viewable in [compare view](microsoft/kiota-dotnet@v2.1.1...v2.1.2). </details> Updated [Microsoft.Kiota.Serialization.Multipart](https://github.com/microsoft/kiota-dotnet) from 2.1.1 to 2.1.2. <details> <summary>Release notes</summary> _Sourced from [Microsoft.Kiota.Serialization.Multipart's releases](https://github.com/microsoft/kiota-dotnet/releases)._ ## 2.1.2 ## [2.1.2](microsoft/kiota-dotnet@v2.1.1...v2.1.2) (2026-09-08) ### Bug Fixes * **serialization-json:** honor custom TimeSpan converters ([#795](microsoft/kiota-dotnet#795)) ([e22c5ba](microsoft/kiota-dotnet@e22c5ba)) * **serialization-json:** honor DateTimeOffset converters ([802e20a](microsoft/kiota-dotnet@802e20a)) * **serialization-json:** honor guid converters before fallback parsing ([#794](microsoft/kiota-dotnet#794)) ([22cc1d3](microsoft/kiota-dotnet@22cc1d3)) Commits viewable in [compare view](microsoft/kiota-dotnet@v2.1.1...v2.1.2). </details> Updated [Microsoft.Kiota.Serialization.Text](https://github.com/microsoft/kiota-dotnet) from 2.1.1 to 2.1.2. <details> <summary>Release notes</summary> _Sourced from [Microsoft.Kiota.Serialization.Text's releases](https://github.com/microsoft/kiota-dotnet/releases)._ ## 2.1.2 ## [2.1.2](microsoft/kiota-dotnet@v2.1.1...v2.1.2) (2026-09-08) ### Bug Fixes * **serialization-json:** honor custom TimeSpan converters ([#795](microsoft/kiota-dotnet#795)) ([e22c5ba](microsoft/kiota-dotnet@e22c5ba)) * **serialization-json:** honor DateTimeOffset converters ([802e20a](microsoft/kiota-dotnet@802e20a)) * **serialization-json:** honor guid converters before fallback parsing ([#794](microsoft/kiota-dotnet#794)) ([22cc1d3](microsoft/kiota-dotnet@22cc1d3)) Commits viewable in [compare view](microsoft/kiota-dotnet@v2.1.1...v2.1.2). </details> Updated [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 18.9.0 to 18.11.0. <details> <summary>Release notes</summary> _Sourced from [Microsoft.NET.Test.Sdk's releases](https://github.com/microsoft/vstest/releases)._ ## 18.11.0 <!-- Release notes generated using configuration in .github/release.yml at rel/18.11 --> ## What's Changed * Fix TRX logger mangling astral-plane (non-BMP) characters by @azat-msft in microsoft/vstest#16318 * Disable the MTP testhost by default by @nohwnd in microsoft/vstest#16337 * Fix OS-blind apphost probe in MTP bridge on Unix (regression from #16201) by @azat-msft in microsoft/vstest#16336 * Retarget the MTP client onto Microsoft.Testing.Platform.ServerMode.Client.Sources by @nohwnd in microsoft/vstest#16300 * Pass arguments to PowerShell with -File instead of -command by @nohwnd in microsoft/vstest#16363 * Respect console logger verbosity from a settings file by @nohwnd in microsoft/vstest#16044 * Fix backslash normalization in VSTestCLIRunSettings on Unix by @nohwnd in microsoft/vstest#15795 * Docs: fix typo explicitely -> explicitly by @vaibhav8a in microsoft/vstest#16397 * Copy acceptance test diagnostic logs into the test results directory by @nohwnd in microsoft/vstest#16403 ## New Contributors * @vaibhav8a made their first contribution in microsoft/vstest#16397 **Full Changelog**: microsoft/vstest@v18.10.1...v18.11.0 ## 18.10.1 ## What's Changed * Isolate code coverage files in published output by @azat-msft in microsoft/vstest#16476 **Full Changelog**: microsoft/vstest@v18.10.0...v18.10.1 ## 18.10.0 ## What's Changed * Drop Mono fallback, run .NET Framework tests on Windows only by @nohwnd in microsoft/vstest#16158 * Run Microsoft.Testing.Platform test apps under `vstest.console` and datacollector by @nohwnd in microsoft/vstest#16201 * Fix test output eaten by MSBuild terminal logger by @nohwnd in microsoft/vstest#16223 * Remove the experimental test session feature by @nohwnd in microsoft/vstest#16231 * Skip a single bad executor instead of failing all executor loading by @nohwnd in microsoft/vstest#16239 * Assert apartment state instead of using Clipboard in UI tests by @nohwnd in microsoft/vstest#16270 * Surface test host crashes during protocol negotiation by @nohwnd in microsoft/vstest#16285 * Pass the inferred target platform to the host in run settings by @nohwnd in microsoft/vstest#16271 * Report raw invalid IsTargetPlatformInferred value, cover host x64 forcing by @nohwnd in microsoft/vstest#16295 * Disable the MTP testhost by default (#16337) by @nohwnd in microsoft/vstest#16341 **Full Changelog**: microsoft/vstest@v18.9.0...v18.10.0 Commits viewable in [compare view](microsoft/vstest@v18.9.0...v18.11.0). </details> Updated [microsoft.openapi.kiota](https://github.com/microsoft/kiota) from 1.35.0 to 1.36.1. <details> <summary>Release notes</summary> _Sourced from [microsoft.openapi.kiota's releases](https://github.com/microsoft/kiota/releases)._ ## 1.36.1 ## Added ### Changed - Fixed small issues with release pipelines ## 1.36.0 ## Added - Ruby: an error's `message` returns the property the description marks with `x-ms-primary-error-message`, as the other languages do. An error property named `message` is renamed `message_escaped`, like `MessageEscaped` in C#; when it is a string, `message` still returns it. [kiota-ruby#63](microsoft/kiota-ruby#63) ### Changed - Fixed relative description paths when opening or selecting clients in the VS Code Kiota workspace. - Removed the retired lock-search command from the VS Code command palette. Lock-file migration remains available. - Preserve inherited properties when a single `oneOf` or `anyOf` member defines its properties only through `allOf`. Fixes [#6778](microsoft/kiota#6778). - Python: preserve false, zero, empty strings, and empty collections when parsing and serializing union type wrappers. - All language refiners accept a generation logger consistently, retaining configuration-only compatibility constructors hidden from IntelliSense. - Reject plugin-manifest file references whose path components become parent-directory traversal after Windows trims trailing spaces or dots. - Fixed a stack overflow when generating API plugins from descriptions with cyclic `allOf` schemas. - Dart: omit unsupported schema defaults with a generation warning, preserve supported literal and enum property and parameter defaults (including empty strings), initialize query parameters from schema defaults, and keep constructor initialization valid with or without backing stores. - Dart: preserve nullable optional request-builder constructor parameters, including UUIDs and collections, so cloning accepts null arguments without overwriting existing path parameters. - Dart: escape URL templates once at final emission to preserve literal dollar signs and backslashes in constructor defaults and method overrides. - Dart: preserve schema string defaults named `null`, including enum wire values, without treating them as JSON-null sentinels. - Dart: preserve query-parameter defaults inside single-member `allOf` wrappers, retaining outer-default precedence and explicit JSON-null defaults. - Dart: validate parser-backed date, time, and UUID defaults before emission, omitting unsupported values with a generation warning. - Ruby: a union of object types that no discriminator decides, such as a oneOf without a discriminator, now reads the payload into every object member, as TypeScript does, instead of returning an empty wrapper. A union whose discriminator matched no member does the same, and its array member is only read when no other member was picked. Requires the runtime gems at 0.24.0. - Ruby: enum members hold their wire value, so a value such as `incoming-payment` or `read` is sent and read as the description declares it instead of as `IncomingPayment` or `Read`. `Enum[:Name]` now returns the wire value as a string. Requires the runtime gems at 0.24.0. - Go: keep escaped namespace segments lowercase so imports match generated package directories on case-sensitive filesystems. Fixes [#7828](microsoft/kiota#7828). - TypeScript: import response enum objects for request builders reached through path parameters. [#6884](microsoft/kiota#6884) - Resolve enum query parameters wrapped in single-member `allOf` schemas, including enum array items. - Go: cast scalar enum values in union factories and avoid reading an empty discriminator name for undiscriminated unions. Addresses [#7808](microsoft/kiota#7808). - Preserve models for multipart properties with default content types when other properties specify an encoding. [#7342](microsoft/kiota#7342) - Dart: escape enum options named value or values to avoid conflicts with generated and built-in enum members. [#7807](microsoft/kiota#7807) - Ruby: the client's root module has an `eager_load!` method that loads every autoloaded model, for servers that preload before forking. - Ruby: generated files start with `# frozen_string_literal: true`, so string default values handed to user code are frozen. - Ruby: generated string literals are double quoted, the StandardRB convention. - Ruby: namespaces with nothing to autoload no longer get an empty barrel file, and generated files no longer require them (561 fewer files in a GitHub client). - Ruby: a client generated with a multi-segment `--namespace-name`, such as `integration_test.client`, failed to load because its root file was written one directory too deep. - Ruby: namespace barrels register their models and enums with `autoload` instead of requiring them, so a subclass no longer fails to load when its base class file is required first. Other files require the barrel rather than an individual model file, and models now load on first use. A type no barrel autoloads, such as a model named after its namespace, is now required directly: 1,315 constants referenced by a Meraki client never loaded, and a client generated from the current GitHub description failed to load because it required a file that is never written. [#7956](microsoft/kiota#7956) - Ruby: model properties are declared with `attr_accessor`, which removes the thousands of "possibly useless use of a variable" warnings `ruby -w` printed while loading a client. - Ruby: enum hashes are frozen. [kiota-ruby#68](microsoft/kiota-ruby#68) - C#: escape Unicode line and paragraph separators in generated string literals so generated clients remain valid C# source. - External reference allowlist wildcards no longer cross the URI authority boundary, so a wildcard in the scheme or host cannot match text in the path, the user information or the port. - Initialize inherited Dart model fields in constructor initializer lists. - Replace only unresolved binary types with a native stream type, and translate a resolved model by its definition rather than its name, so a model whose schema is named `binary`, `base64` or `base64url` keeps its own name across every language instead of being rendered as the native binary type. Generation no longer fails for C# and Java. - Avoid redundant parsing branches for equivalent binary alternatives in Dart and PHP composed models. - Preserve imports for distinct types from the same namespace when inlining error model inheritance. - Dart: qualify model fields named `node` or `deserializerMap` during deserialization so local variables do not shadow them; escape `override` model members to preserve Dart annotations. Fixes [#7822](microsoft/kiota#7822). - PHP: disambiguate enum constants that normalize to the same name while preserving wire values and existing constant names. - Java: omit unused discriminator-mapping imports for union/intersection wrappers, avoiding imports of nonexistent models while retaining member and inherited-factory imports. - Dart: omit unused discriminator-mapping imports for composed wrappers while preserving member and inherited-factory imports. Addresses [#7821](microsoft/kiota#7821). - Preserve endpoints whose static path segments collide after name sanitization, such as /v1.1 and /v11. [#7143](microsoft/kiota#7143) - Ruby: a path with an escaped suffix, such as `/domains/{domainName}!quote`, generated a request builder method that passed the raw path parameter name where the signature had snake cased it, and referenced the builder class without its namespace. Both raised `NameError` on first use. [#7956](microsoft/kiota#7956) ... (truncated) Commits viewable in [compare view](microsoft/kiota@v1.35.0...v1.36.1). </details> Updated [xunit.runner.visualstudio](https://github.com/xunit/visualstudio.xunit) from 4.0.0 to 4.0.1. <details> <summary>Release notes</summary> _Sourced from [xunit.runner.visualstudio's releases](https://github.com/xunit/visualstudio.xunit/releases)._ ## 4.0.1 Release notes: https://xunit.net/releases/visualstudio/4.0.1 Commits viewable in [compare view](xunit/visualstudio.xunit@4.0.0...4.0.1). </details> Updated [xunit.v3](https://github.com/xunit/xunit) from 4.0.0 to 4.0.2. <details> <summary>Release notes</summary> _Sourced from [xunit.v3's releases](https://github.com/xunit/xunit/releases)._ No release notes found for this version range. Commits viewable in [compare view](https://github.com/xunit/xunit/commits). </details> Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore <dependency name> major version` will close this group update PR and stop Dependabot creating any more for the specific dependency's major version (unless you unignore this specific dependency's major version or upgrade to it yourself) - `@dependabot ignore <dependency name> minor version` will close this group update PR and stop Dependabot creating any more for the specific dependency's minor version (unless you unignore this specific dependency's minor version or upgrade to it yourself) - `@dependabot ignore <dependency name>` will close this group update PR and stop Dependabot creating any more for the specific dependency (unless you unignore this specific dependency or upgrade to it yourself) - `@dependabot unignore <dependency name>` will remove all of the ignore conditions of the specified dependency - `@dependabot unignore <dependency name> <ignore condition>` will remove the ignore condition of the specified dependency and ignore conditions </details> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Steinar Hjellvik <38071413+shjellvik@users.noreply.github.com>
Add
MSAL_MI_DISABLE_IMDS_V2kill switchFixes #6174
Environment-variable kill switch that disables IMDSv2 for a process, so a host hitting an IMDSv2 problem can fall back to IMDSv1 without waiting for an MSAL release. Enabled by default; honored for
true(case-insensitive) and1. Anything else is ignored, so a typo cannot quietly weaken token binding.Two product files: one env-var read, and the two places that consult it.
WithMtlsProofOfPossession()MsalError.MtlsPopTokenNotSupportedinImdsV1WithRequestOverMtls()MsalError.MtlsPopTokenNotSupportedinImdsV1WithMtlsProofOfPossession(...)with aMinStrengthfloorMsalError.MinStrengthNotMetGetManagedIdentityCapabilitiesAsync()MaxSupportedBindingStrength = NoneA restart is required
MSAL reads the process environment. Nothing outside the process can modify that block — Windows exposes no supported API, and
/proc/<pid>/environis read-only on Linux — so an edit made at the machine, service, or container level is invisible to an already-running process. Setting or clearing the variable takes effect only after a restart or recycle.This is mechanics rather than a design choice, and it costs nothing in practice: the deployment mechanisms that would set the variable — app restart, container replacement, VM reimage — all restart the process anyway. A process can still change its own block through
Environment.SetEnvironmentVariable, which is how the tests exercise both states, but nothing in a real deployment does. The value is settled before the first call, so there is no warm-cache state to reconcile.mTLS requests fail fast
WithMtlsProofOfPossession()andWithRequestOverMtls()are served exclusively by IMDSv2 and have no IMDSv1 equivalent, so both throw rather than return a token. A plain request getsMtlsPopTokenNotSupportedinImdsV1, the error MSAL already raises on a host with no IMDSv2 support. A request carrying aMinStrengthfloor is measured against the reportedNoneby the pre-existing floor check and getsMinStrengthNotMetinstead.They throw rather than fall back because the caller opted into something IMDSv1 cannot provide and has no way to notice that a weaker result came back instead. The two APIs ask for different things —
WithMtlsProofOfPossession()for a certificate-bound token,WithRequestOverMtls()for a bearer token issued over an mTLS connection — and neither is reachable without IMDSv2. Reusing the existing code is deliberate: to the caller the situation is the same either way — mTLS is unavailable here — and the log records which cause applies. The existing message attributes the failure to the VM image, which is accurate for a genuinely v1-only host but not when the switch is the cause; the log line is what separates the two.Capability discovery reports no binding support
While the switch is set,
GetManagedIdentityCapabilitiesAsync()reportsMaxSupportedBindingStrength = NoneandIsMtlsPopSupportedByHost = false.Callers use this API to decide up front whether to ask for a bound token. Reporting the host's hardware capability while the switch is on would let a chain such as
DefaultAzureCredentialconfidently pick the PoP path and then fail on every token request. Reporting what the caller can actually obtain keeps them on the bearer path. This does narrowMaxSupportedBindingStrengthfrom hardware capability to effective availability; the two already diverge on a v1-only host, which is graded even though it can never mint a bound token.MSAL therefore also skips the IMDSv1 binding-strength probe: with no route to a bound token there is nothing to grade, and the check would only cost an HTTP call.
Two enforcement points
An mTLS request does not always run discovery. With no
MinStrengthfloor, the binding path skips the capability call and routes straight to IMDSv2, so a check placed only in discovery is never reached on that path — with the switch on, the call still returnstokenType=mtls_popand a provisioned certificate. I verified that directly before adding the second check.GetManagedIdentityCapabilitiesAsyncSelectManagedIdentitySourceTypeThe second adds no rejection logic of its own. It converts an early return into a fall-through so the request reaches the IMDSv1 mTLS guard that already exists, and that guard throws.
Environment-detected sources (App Service, Cloud Shell, and the rest) are untouched. IMDSv2 is never involved there, so they keep their existing
MtlsPopNotSupportedForEnvironmenterror, which diagnoses those hosts more accurately.Tests
11 cases across 5 methods in
ImdsV2Tests.cs: value parsing (true/True/1disable; unset, empty,false,yesdo not), discovery resolving to IMDSv1 with no binding support, repeated discovery, bearer over IMDSv1, and both mTLS shapes throwing.The mocks carry most of the assertion. Only IMDSv1 handlers are queued, and
MockHttpManagerfails both on an unmatched request and on an unconsumed mock, so the tests prove that no IMDSv2 probe, CSR, or certificate call was issued and that the binding-strength probe no longer fires.Teeth verified by mutation: with the switch forced to report "not disabled", 7 of the 11 fail. The 4 that still pass are the switch-off rows, which should pass.
Full ManagedIdentity suite: 473 passed, 1 skipped, 0 failed. Build clean, 0 warnings.
Compatibility
No public API change and no new error code, so
PublicAPI.Unshipped.txtis untouched.One intentional behavior change on an existing public API: while the switch is set,
GetManagedIdentityCapabilitiesAsyncreports no binding support on a host that would otherwise advertise it. That is the purpose of the switch — a caller must not be told PoP is available and then be thrown at on every request. It occurs only when the variable is set, so default behavior is unchanged.Checked
Microsoft.Identity.Webfor the affected APIs. It calls none of the capability APIs (GetManagedIdentityCapabilitiesAsync,MaxSupportedBindingStrength,IsMtlsPopSupportedByHost,ManagedIdentityCapabilities,MtlsBindingStrength) and does not useWithRequestOverMtls, so it cannot observe this change. Its threeWithMtlsProofOfPossession()call sites each sit behind an explicit opt-in flag (bindToCertificate,isTokenBinding) and are unaffected unless the variable is set.Docs
docs/msi_v2/imds_v2_kill_switch.mdcovers accepted values, the restart requirement, and both enforcement points.guidance_for_sdks_consuming_msal.mdgets a pointer, since SDK authors branching on capabilities are the audience most affected.assistance: agentic-cli
type: security
agent-tool: copilot-cli
agent-model: claude-opus-5
work-item: AB#n/a