Skip to content

[Bug] RuntimeBroker crashes with NullReferenceException when macOS SSO extension is inactive #5941

@TomProkop

Description

@TomProkop

Summary

In this repro environment, the macOS broker path ends in NullReferenceException after broker startup fails.

Environment

  • Microsoft.Identity.Client.Broker 4.83.3
  • Microsoft.Identity.Client.NativeInterop 0.20.3
  • .NET 10.0.105
  • macOS 26.3.1, arm64

Repro

Observed through an app using the macOS broker path (WithBroker(new BrokerOptions(OperatingSystems.OSX))) and also confirmed by calling the native runtime directly.

Direct native call result:

  • MSALRUNTIME_Startup() returns ApiContractViolation (status 6)
  • context: SSO extension is inactive or is not available on this device.

Decompiled RuntimeBroker behavior:

  • RuntimeBroker catches MsalRuntimeException with ResponseStatus.ApiContractViolation
  • stores it in s_initException
  • returns null from the Lazy<Core> factory
  • later uses of s_lazyCore.Value are not null-checked and end in NullReferenceException

Expected behavior

If broker startup is unavailable, MSAL should surface a descriptive exception or broker-unavailable result. It should not degrade into NullReferenceException.

Notes

This issue is intentionally scoped to the environment above. Related consumer repro: microsoft/powerplatform-build-tools#1352

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions