Repository navigation
Description
Library and version
Microsoft.Identity.Web 4.14.2, using CredentialSource.SignedAssertionFromManagedIdentity for application token acquisition on .NET 10.
Describe the bug
A transient failure while initially loading a managed-identity client assertion can leave the shared credential description permanently skipped. Subsequent application-token requests then fail with IDW10109 without retrying assertion loading, even after the original dependency failure has recovered.
Reproduction
- Configure application-token acquisition with a
SignedAssertionFromManagedIdentityclient credential and keep the token-acquisition services alive across requests. - During the first assertion load, inject a single
MsalServiceExceptionfrom managed-identity token acquisition, representing a temporary endpoint/network failure. - Restore successful managed-identity token acquisition without restarting the process or replacing its service provider.
- Request an application token again using the same services and credential description.
Actual: Later requests fail with IDW10109. The credential remains Skip = true, so the credential-loading path is not attempted again.
Expected: A transient managed-identity failure should not permanently disable this credential for the lifetime of the process. A later request should be able to retry with bounded backoff once the dependency recovers, while still propagating authentication failures and respecting cancellation.
Source-level observations
In the 4.14.2 sources:
- SignedAssertionFromManagedIdentityCredentialLoader sets
credentialDescription.Skip = truewhen assertion loading throwsMsalServiceException. - CredentialsProvider attempts loading only when
Skipis false. When no signed-assertion credential can be selected, it throws IDW10109. - DefaultCredentialsLoader.ResetCredentials clears
Skipand the cached credential value, but there appears to be no automatic recovery of this initial-load failure in the normal acquisition path.
Workaround
Calling the public ICredentialsLoader.ResetCredentials API on the affected live credential descriptions allows a subsequent request to load the assertion and obtain the application token. Recreating the token-acquisition services also removes the stuck state.
Suggested regression test
Inject one transient failure into the initial managed-identity assertion load, restore the simulated dependency, and verify that a later request obtains the final application access token using the same long-lived services, without an application-issued credential reset or process restart.
Activity
berndverst commentedon Oct 1, 2026
FYI - we run into this issue when using User Managed Identities on App Service which we have federated with our First Party App. We perform the client assertion token exchange from Managed Identity credential to then call checkAccess API for RBAC admission decisions.
This limitation here makes it very difficult to seamlessly recover dataplane RBAC. We need Microsoft.Identity.Web to have a mechanism to retry / reload credentials - ignore skipped etc.
Note - we are not direct consumers of Microsoft.Identity.Web.
Our backend → MISE → Microsoft.Identity.Web → MSAL → managed-identity / Entra endpointsberndverst commentedon Oct 1, 2026
Bogdan Gavril (@bgavrilMS) I saw you commented on an issue related in nature. Perhaps you can chime in here? :)
bgavrilMS commentedon Oct 1, 2026
Hi Bernd Verst (@berndverst) - I believe Neha Bhargava (@neha-bhargava) just fixed this and released Identity.Web. Neha Bhargava (@neha-bhargava) - can you please confirm?
bgavrilMS commentedon Oct 1, 2026
IMO there are 2 options:
Solution 2 is safer, but solution 1 is better for reliability.
berndverst commentedon Oct 1, 2026
Thanks for looking into this. I reviewed the default branch (
master) at commit9c5066ed6c05, and the persistent-skip behavior still appears present for our configuration.We explicitly configure both the authority and
TokenExchangeUrlfor deployments across multiple clouds, including Azure US Government. We need recovery to work with those values explicitly supplied.The failure path still appears present
SignedAssertionFromManagedIdentityCredentialLoaderstill catchesMsalServiceException, setscredentialDescription.Skip = true, and rethrows.CredentialsProviderstill enters the credential-loading path only when!credential.Skip. Subsequent calls therefore skip the affected credential.invalid_clienterrors, rather than the initialmanaged_identity_unreachable_networkfailure described here.The per-request credential copy does not cover explicit
TokenExchangeUrlThere is a per-request copy for cloud-specific audience resolution, but it is conditional on:
SourceType == SignedAssertionFromManagedIdentityTokenExchangeUrlbeing emptyThat copy can prevent a failed load from marking the shared original credential skipped when the audience is inferred. With an explicit
TokenExchangeUrl, however, the copy is not made: the loader operates on the shared credential description and can leave it permanently skipped.Suggested regression coverage
Please include a case with both authority and
TokenExchangeUrlexplicitly configured:SignedAssertionFromManagedIdentitycredential.MsalServiceExceptionduring initial assertion loading.ResetCredentials()call, service-provider replacement, or process restart.This assessment is based on the source at the commit above. Could you link the fix/PR and released version you had in mind, and confirm whether it covers the explicit-
TokenExchangeUrlcase?berndverst commentedon Oct 2, 2026
Additional production background: this was the original temporary failure that caused our only configured
SignedAssertionFromManagedIdentitycredential to be markedSkip = true:The failure occurred while obtaining the managed-identity assertion from the local token service, before exchanging it for the application's access token. Once Identity Web marked that credential skipped, subsequent requests could not recover even after the dependency recovered: there was no second credential to fall back to. We explicitly configure both authority and
TokenExchangeUrl.Why MSAL's retries did not prevent this
We checked MSAL 4.84.2, matching the production exception, and reproduced the behavior using the published NuGet package with a mocked App Service HTTP transport:
HttpRequestExceptionwrappingSocketException(10061)on its first invocation. This test does not injectMsalServiceException; MSAL creates it.MsalServiceExceptionwithmanaged_identity_unreachable_networkafter one transport attempt, with zero automatic retries.IManagedIdentityApplicationinstance succeeds. No application replacement or reset is needed at the MSAL layer. No real endpoint was contacted in this reproduction.The 4.84.2 source explains this:
HttpManager.SendRequestAsynccatches timeout-relatedTaskCanceledExceptionbefore its retry loop. AnHttpRequestExceptionescapes before reaching that loop.HttpRequestException.AbstractManagedIdentity.HandleExceptionwraps that exception asmanaged_identity_unreachable_network, preserving the underlying failure.This was a connection refusal, not an HTTP 429/5xx response or a timeout. For the App Service flow, MSAL reads the local endpoint from
IDENTITY_ENDPOINT; the port is not hard-coded by MSAL. The exception itself does not establish why that local endpoint was temporarily unavailable.There are two separate resilience concerns: MSAL could potentially add bounded retries for this class of transient MI connection failure, but Identity Web must still allow later recovery after an acquisition fails. Even an improved bounded retry policy can eventually give up. That must not permanently disable the only configured credential. The persistent-skip fix in #4081 is therefore necessary independently of any MSAL retry improvement.
berndverst commentedon Oct 2, 2026
Perhaps a different solution could be:
If all credentials are marked as Skip=True throw?