Skip to content

Make managed identity key attestation optional - #4004

Merged
Gladwin Johnson VR (gladjohn) merged 3 commits into
masterfrom
fix/key-attestation-package
Aug 26, 2026
Merged

Gladwin Johnson VR (gladjohn) merged 3 commits into
masterfrom
fix/key-attestation-package

Conversation

@gladjohn

Copy link
Copy Markdown
Contributor

Problem

Microsoft.Identity.Web.Certificateless currently references Microsoft.Identity.Client.KeyAttestation. That dependency transitively brings the native-only Microsoft.Azure.Security.KeyGuardAttestation package into applications that never request key attestation, including consumers that arrive through Microsoft.Identity.Web.TokenAcquisition and Microsoft.Identity.Web.Azure.

NuGet dependencies cannot be conditioned on whether an API is used, so keeping the reference in Certificateless means every consumer receives the native DLL and PDB. It also creates compatibility problems for .NET Framework / packages.config consumers. See AzureAD/microsoft-authentication-library-for-dotnet#6133.

Change

This PR separates managed identity mTLS PoP from optional Credential Guard key attestation:

  • Keeps Microsoft.Identity.Web.Certificateless independent through the IManagedIdentityAttestationProvider extension point.
  • Adds the optional Microsoft.Identity.Web.KeyAttestation package as the only IdWeb package that references Microsoft.Identity.Client.KeyAttestation.
  • Adds AddMicrosoftIdentityWebKeyAttestation() for explicit opt-in.
  • Uses the provider consistently for both managed identity mTLS PoP paths:
    • direct managed identity token acquisition;
    • SignedAssertionFromManagedIdentity / FIC token acquisition.
  • Keeps the custom credential-loader override so the FIC path receives the provider without coupling Certificateless to the optional package.
  • Updates the existing attested FIC E2E test to explicitly register the optional package.
  • Updates packaging, API surface, changelog, and mTLS PoP documentation.

Behavior

Configuration Managed identity mTLS PoP behavior
Default WithMtlsProofOfPossession()
Install Microsoft.Identity.Web.KeyAttestation and call AddMicrosoftIdentityWebKeyAttestation() WithMtlsProofOfPossession() + WithAttestationSupport()

Only applications that opt in receive the native KeyGuard attestation assets. The unattested managed identity mTLS PoP flow remains supported by MSAL.

For TokenAcquirerFactory applications, opt-in is explicit before Build():

var tokenAcquirerFactory = TokenAcquirerFactory.GetDefaultInstance();
tokenAcquirerFactory.Services.AddMicrosoftIdentityWebKeyAttestation();

var serviceProvider = tokenAcquirerFactory.Build();

Review focus

  • IManagedIdentityAttestationProvider is the dependency-inversion seam; the core packages do not reference the optional implementation package.
  • KeyAttestedManagedIdentityCredentialLoader intentionally overrides the built-in SignedAssertionFromManagedIdentity loader through the existing custom-loader mechanism.
  • Absence of the provider intentionally selects the unattested flow and logs that choice once per component instance.
  • No backward-compatibility shim, loader redesign, or broader API redesign is included.

Validation

  • Built the attested TokenAcquirerTests E2E project for net8.0: 0 warnings, 0 errors.
  • Focused KeyAttestationTests: 2 passed.
  • Previously validated the modified credential/attestation test set: 44 passed.
  • Packed and inspected the affected NuGet dependency groups:
    • core Certificateless, TokenAcquisition, and Azure packages do not depend on KeyAttestation;
    • only Microsoft.Identity.Web.KeyAttestation depends on Microsoft.Identity.Client.KeyAttestation.

Move Credential Guard attestation behind an opt-in Identity Web package so ordinary certificateless and token acquisition consumers do not publish the native KeyGuard assets.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: c958606f-3471-4310-8715-83d1081964f5
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: c958606f-3471-4310-8715-83d1081964f5
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: c958606f-3471-4310-8715-83d1081964f5
@gladjohn
Gladwin Johnson VR (gladjohn) marked this pull request as ready for review August 26, 2026 02:40
@gladjohn
Gladwin Johnson VR (gladjohn) requested a review from a team as a code owner August 26, 2026 02:40
@gladjohn
Gladwin Johnson VR (gladjohn) merged commit c7a489c into master Aug 26, 2026
10 checks passed
@gladjohn
Gladwin Johnson VR (gladjohn) deleted the fix/key-attestation-package branch August 26, 2026 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants