-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Add WAM workaround for elevated processes #344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| # Web Account Manager integration | ||
|
|
||
| ## Running as administrator | ||
|
|
||
| The Windows broker ("WAM") makes heavy use of | ||
| [COM](https://docs.microsoft.com/en-us/windows/win32/com/the-component-object-model), | ||
| an IPC and RPC technology built-in to the Windows operating system. In order to | ||
| integrate with WAM, Git Credential Manager and the underlying | ||
| [Microsoft Authentication Library (MSAL)](https://aka.ms/msal-net) | ||
| must use COM interfaces and remote procedure calls (RPC). | ||
|
|
||
| When you run Git Credential Manager as an elevated process, such as when you run | ||
| a `git` command from an Administrator command-prompt or perform Git operations | ||
| from Visual Studio running as Administrator, some of the calls made between GCM | ||
| and WAM may fail due to differing process security levels. | ||
|
|
||
| If you have enabled using the broker and GCM detects it is running in an | ||
| elevated process, it will automatically attempt to modify the COM security | ||
| settings for the running process so that GCM and WAM can work together. | ||
|
|
||
| However, this automatic process security change is not guaranteed to succeed | ||
| depending on various external factors like registry or system-wide COM settings. | ||
| If GCM fails to modify the process COM security settings, a warning message is | ||
| printed and use of the broker is disabled for this invocation of GCM: | ||
|
|
||
| ```text | ||
| warning: broker initialization failed | ||
| Failed to set COM process security to allow Windows broker from an elevated process (0x80010119). | ||
| See https://aka.ms/gcmcore-wamadmin for more information. | ||
| ``` | ||
|
|
||
| ### Possible solutions | ||
|
|
||
| In order to fix the problem there are a few options: | ||
|
|
||
| 1. Do not run Git or Git Credential Manager as elevated processes. | ||
| 2. Disable the broker by setting the | ||
| [`GCM_MSAUTH_USEBROKER`](environment.md#gcm_msauth_usebroker) | ||
| environment variable or the | ||
| [`credential.msauthUseBroker`](configuration.md#credentialmsauthusebroker) | ||
| Git configuration setting to `false`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
src/shared/Microsoft.Git.CredentialManager/Interop/Windows/Native/Ole32.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT license. | ||
| using System; | ||
| using System.Runtime.InteropServices; | ||
|
|
||
| namespace Microsoft.Git.CredentialManager.Interop.Windows.Native | ||
| { | ||
| public static class Ole32 | ||
| { | ||
| private const string LibraryName = "ole32.dll"; | ||
|
|
||
| public const uint RPC_E_TOO_LATE = 0x80010119; | ||
|
|
||
| [DllImport(LibraryName)] | ||
| public static extern int CoInitializeSecurity( | ||
| IntPtr pVoid, | ||
| int cAuthSvc, | ||
| IntPtr asAuthSvc, | ||
| IntPtr pReserved1, | ||
| RpcAuthnLevel level, | ||
| RpcImpLevel impers, | ||
| IntPtr pAuthList, | ||
| EoAuthnCap dwCapabilities, | ||
| IntPtr pReserved3); | ||
|
|
||
| public enum RpcAuthnLevel | ||
| { | ||
| Default = 0, | ||
| None = 1, | ||
| Connect = 2, | ||
| Call = 3, | ||
| Pkt = 4, | ||
| PktIntegrity = 5, | ||
| PktPrivacy = 6 | ||
| } | ||
|
|
||
| public enum RpcImpLevel | ||
| { | ||
| Default = 0, | ||
| Anonymous = 1, | ||
| Identify = 2, | ||
| Impersonate = 3, | ||
| Delegate = 4 | ||
| } | ||
|
|
||
| public enum EoAuthnCap | ||
| { | ||
| None = 0x00, | ||
| MutualAuth = 0x01, | ||
| StaticCloaking = 0x20, | ||
| DynamicCloaking = 0x40, | ||
| AnyAuthority = 0x80, | ||
| MakeFullSIC = 0x100, | ||
| Default = 0x800, | ||
| SecureRefs = 0x02, | ||
| AccessControl = 0x04, | ||
| AppID = 0x08, | ||
| Dynamic = 0x10, | ||
| RequireFullSIC = 0x200, | ||
| AutoImpersonate = 0x400, | ||
| NoCustomMarshal = 0x2000, | ||
| DisableAAA = 0x1000 | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.