Skip to content

Conversation

@mjcheetham
Copy link
Contributor

Add a workaround to a broker bug whereby the account control does not appear when running from an elevated process.

AzureAD/microsoft-authentication-library-for-dotnet#2560

The underlying issue is to do with COM and the OS account control not being able to call-back in to the elevated process.

The workaround is to set the process COM security to "none" iif we are on Windows 10, the process is elevated, and the user hasn't disabled the broker.

It is possible the call to CoInitializeSecurity may fail, as this can only be called once in the lifetime of a process, and must be called before any COM interactions occur. The CLR may perform some COM interop before we even get to the Main method(!)

We try our best here and call the CoInitializeSecurity function as soon as we reasonably can in the lifetime of our process.

@mjcheetham mjcheetham added bug A bug in Git Credential Manager experimental Specific to an experimental feature platform:windows Specific to the Windows platform auth:microsoft Specific to Microsoft AAD/MSA authentication labels May 13, 2021
if (!PlatformUtils.IsWindows10()) return;

// Nothing to do when not an elevated user
if (!PlatformUtils.IsElevatedUser()) return;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pmaytak - I think we should have this (lines 58 - 83) as a helper in MSAL

Add a workaround to a broker bug whereby the account control does not
appear when running from an elevated process.

AzureAD/microsoft-authentication-library-for-dotnet#2560

The underlying issue is to do with COM and the OS account control not
being able to call-back in to the elevated process.

The workaround is to set the process COM security to "none" iif we are
on Windows 10, the process is elevated, and the user hasn't disabled the
broker.

It is possible the call to CoInitializeSecurity may fail, as this can
only be called once in the lifetime of a process, and must be called
before any COM interactions occur. The CLR may perform some COM interop
before we even get to the Main method(!)

We try our best here and call the CoInitializeSecurity function as soon
as we reasonably can in the lifetime of our process.
@mjcheetham mjcheetham merged commit 301f888 into git-ecosystem:master May 14, 2021
@mjcheetham mjcheetham deleted the wam-elevate branch May 14, 2021 08:19
@mjcheetham mjcheetham mentioned this pull request May 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auth:microsoft Specific to Microsoft AAD/MSA authentication bug A bug in Git Credential Manager experimental Specific to an experimental feature platform:windows Specific to the Windows platform

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants