You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Silent install of "winget install git.git" is not working #797
I am trying to use winget install to install git remotely. When running through a remote session the install hangs because I suspect the installer is waiting for an interaction as it has not gone silent. When I run the silent mode on a local powershell with administrator I get the dialog pop. How can I guarantee silent mode for all potential apps?
The dropbox link shows my winget --info as well as the install command failing to run silently and popping up the installer dialog. I am using a powershell in Administrator mode. Eventually I want this to work over a remote session but Im surprised to run up against this immediately. I also tried Notepad++ with the same issue.
Is SmartScreen enabled on the target machine? If it is disabled, the prompts appear under certain scenarios regardless of what flags are passed to winget (since it's Windows putting them up, not winget).
#703 has some discussion of this issue, but the problem should have been fixed in the last release of winget (which you have)...
So I checked SmartScreen settings on all systems. They were all turned off but a few of them had a warning link to the top right of the toggle button that I clicked which popup up a security dialog asking me to confirm. Once I did this I clearly confirmed winget isntall git.git --silent worked on one computer. Then I did the same check on another computer and it didnt fix the issue. I noticed the user interface for this section was slightly different on each computer - so I updated everything to 20H2.
So now I have all systems up to date but 1 computer still forces the popup. Here is an image of the security toggles and the shell output.
As well I just tried turning off the toggles for Edge and the MS Store Apps but still have same issue.
On that system, you need to check "Check apps and files" for the security warning to go away. If Windows checks the file against SmartScreen, it is sure enough that the file isn't malware so it doesn't have to ask you.
Oh wow you are correct. However on the other two systems that checkbox is off. Any ideas what the difference might be? Will check next what happens when I normalize everything.
As well thanks for the tip - yes this is scaling up to 15 new systems so I really appreciate the pointer. Thanks for making winget just found out about it a few days ago and Im really excited to tell our community about it.
Edit: I guess you already mentioned the flags passed along to winget aren't necessarily in sync with the user interface. The solution therefore would be to turn them off and on?
"Check apps and files" means that Windows sends a signature from the file to Microsoft to see if it is malicious before opening the file, and in 20H2 they broke this out from the other SmartScreen settings to make it more clear what is going on I think (although someone may know more about it than I do).
The flags passed to winget don't control SmartScreen, it's a different application (and if passing silent to winget caused SmartScreen settings to change that would break a lot of stuff in corporate environments). The settings in the Defender control panel should be what is being applied (and will be greyed out if you use GPO instead).
Easton Pillay (@jedieaston) you seem to be familiar with Group Policy. Would you mind taking a look at some of the policies for the Windows Package Manager? #154
I think we're going to rename them to be more generic "App Installer" since that is what we ship in, so "Windows Package Manager" might become "App Installer" for the policy titles, but the descriptions are pretty close to what we're thinking.
Jarrett Smith (@jarrettgsmith) we haven't determined the best path forward for remote execution. Many installers require UAC or have some sort of dialog box. I think remote scenarios may require some additional work in the manifest and the client. I don't know if anybody has created an Issue to address remote scenarios off the top of my head.
Here is what we do when downloading and executing an installer:
Always set "Mark of the Web" with ZoneIdentifier URLZONE_INTERNET(3) when downloading the installer.
Verify the installer SHA256
If the hash does not match: Leave "Mark of the Web" at URLZONE_INTERNET(3)
If the hash matches:
If the installer is from a trusted source, modify "Mark of the Web" to ZoneIdentifier URLZONE_TRUSTED(2)
If the installer is from an untrusted source, call Attachment Execution Service to trigger anti virus and determine ZoneIdentifier
I move my internal website to zone 2 (trusted) instead of 1 (internal) sorry if I'm confused with 1/2/3 ...
When I download it from edge there is no problem but in fact the file have no zone at all.
PS C:\Users\Administrateur\Downloads> Get-Content .\AutoIt.3.3.14.5.x64.exe -Stream Zone.Identifier
Get-Content : Impossible d’ouvrir l’autre flux de données «Zone.Identifier» du fichier «
C:\Users\Administrateur\Downloads\AutoIt.3.3.14.5.x64.exe».
Wherase the file downloaded from winget (which I delete myself before runing install) have zone 3
2021-06-14 23:38:02.918 [CLI ] Installer hash verified
2021-06-14 23:38:02.919 [CORE] Started applying motw using IAttachmentExecute to C:\Users\Administrateur\AppData\Local\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\TempState\WinGet\AutoIt.AutoIt.3.3.14.5
2021-06-14 23:38:05.208 [CORE] Finished applying motw using IAttachmentExecute. Result: 0 IAttachmentExecute::Save() result: 0
So it looks like winget did not identify my website correcltly as the flag InstallerTrusted is not set ? if (WI_IsFlagSet(context.GetFlags(), Execution::ContextFlag::InstallerTrusted)) { Utility::ApplyMotwIfApplicable(context.Get<Execution::Data::InstallerPath>(), URLZONE_TRUSTED); } else if (WI_IsFlagSet(context.GetFlags(), Execution::ContextFlag::InstallerHashMatched)) { const auto& installer = context.Get<Execution::Data::Installer>(); HRESULT hr = Utility::ApplyMotwUsingIAttachmentExecuteIfApplicable(context.Get<Execution::Data::InstallerPath>(), installer.value().Url);
I have to further read the source code to understand how the flag is set, should't it be set based on internet setting ? if (context.Contains(Execution::Data::PackageVersion) && context.Get<Execution::Data::PackageVersion>()->GetSource() != nullptr && WI_IsFlagSet(context.Get<Execution::Data::PackageVersion>()->GetSource()->GetDetails().TrustLevel, SourceTrustLevel::Trusted)) { context.SetFlags(Execution::ContextFlag::InstallerTrusted); }
Then I do not understand what ApplyMotwUsingIAttachmentExecuteIfApplicable is doing but I guess it changed nothing to the zone as there is no further result for ApplyMotwIfApplicable neither for IZoneIdentifier. Should I do something to refresh / apply my internet settings ? Actually what is a trusted zone from winget point of view ?
Just to clarify, I'm seeing the same security warning as others comments and I'm not able to silently install packages with winget. This is not related to any specific manifest but rather to the way I mirror the winget repository and internalise the deployment.
winget --info
Windows Package Manager v1.0.11451
Copyright (c) Microsoft Corporation. Tous droits réservés.
Windows: Windows.Desktop v10.0.19042.1052
Package: Microsoft.DesktopAppInstaller v1.11.11451.0
After reading more code, even if I'm not used to cpp. The source check is not checking the installer url but rather the source from which the manifest came from.
I'm using "-m" to install from a local manifest
In this case, I guess GetSource() return nullprt as the manifest did not came from any source. Am I just ?
As smartscreen is disable (I have to try with this feature enable), or, maybe, if I don't have internet access
The Attachment Execution Service which trigger anti virus and determine ZoneIdentifier do not report any error but still consider the executable as comming from Internet thus the Zone.Identifier does not change. I'm not sure if this step should change the Zone.Identifier but at the end Windows security feature prevent installer execution as it was not able to verify its footprint with smartscreen. Is it normal the Zone.Identifier does not change even after a successfull anti-virus validation ?
Actually there is no easy solution for my use case which is standalone offline deployment.
Is there any plan to mirror public repository and even installers (internal mirror - not sure about licence if this is considerd as redistribution clause) ?
May I suggest you change the Zone.Identifier after antivirus checks if there is no error ?
May I suggest you check the installer source url againt internet settings to identify the correct Zone.Identifier ? (after antivirus checks maybe or before to qualify the source as trusted ... then what about local manifest without source ...)
The second point may be the easiest one but this depends on your security policy (which I understand but still I think you prevent/ignore Administrator settings).
For sure there is other solution, what do you think should be done even if standalone offline installation is not a priority feature ?
I'm going to to workaround this issue with $env:SEE_MASK_NOZONECHECKS=1 to make progress until there is a proper solution.
I'll talk with the engineering team, and the security team to look at all of the implications. We may need to look at adding some features for this scenario.
Is there any plan to mirror public repository and even installers (internal mirror - not sure about licence if this is considerd as redistribution clause) ?
This shouldn't be too hard to add on in a REST source implementation, I was thinking about a similar use case but am waiting for a way to deploy the sample restsource so I can mess with it. The redistribution rights internally shouldn't be a problem, SCCM does it all of the time. You just can't (or shouldn't) make the mirror public without permission from the copyright holders.
Demitrius Nelon (@denelon)
I guive a quick look on REST API. Looks promising. I have no knowledge about C#, Azure, Visual Studio and all those full feature envs but it looks like the database layer depends on Cosmos DB which depend on Azure thus online then I will not be able to use it internaly even if I manage to run it with Mono. I saw you and Easton Pillay (@jedieaston) talk about the database layer which could be abstracted and allow, as exemple, a mongodb backend.
In all case, for standalone / offline deployment, winget-cli should provide a solution to trust an other repository, or apply administrator settings to identify known url installer or just relax the Zone.Identifier (zone 1 or 2 or just unblock the file, remove the identifier).
What I have done is easy scripting and it can even be easier without the need to host installers on a local website (which also need a valid https certificate if I did not mess things during my test). Initially I wanted to bring all of these into an usb hard drive with simple powershell scripts, one to install winget and others to install a list of manifest based on profile you define when you setup your standalone folder with my python script. Then you may also be able to share this folder with correct persmission and run those script to deploy and update packages on a regular basis. This can be seen as a poc for a feature which may be added to winget, let's say a new command named clone. Unfortunatly this is not possible as installer url must be http and this will also break the winget security design by allowing an untrusted hard drive which is not safe.
Easton Pillay (@jedieaston)
What is your use case ?
Initially I started with chocolatey but this still is a lot of handwork with the free version as it's almost impossible to parse and extract the installer to internalise it. With winget it's easy to make a script and I have something which will work if I manage to bring all piece together (even a standalone hard drive if I manage to run a portable web server and make things work without https). Note that for now I'm relying on chocolatey which run winget internally but this can easily be changed to be standalone with simple powersheel script, I just choose to use chocolatey to deploy my configuration and tweeks with powersheel and also benefit from the time I spent learning it as it also could help me in some scenario.
But remember, if you internalise installer and repository, it's at your own risk and, actually, there is a reason why it's not so easy to implement as it's inherently insecure. As an exemple, the application should check the sha256 with a signature (or the whole manifest but then you cannot tweek it which is also a need in some case and maybe if someday we can also do post-install configuration) from the official repository to ensure the original installer and your repository was not altered both, even in your local repository which may be far less safe than the actual security measure implemented by the official repository. For sure if you then want to deploy an unofficial package or an internal application, it looks like this tool is not intended for you but still winget can allow administrator to configure that. Note this does not prevent testers from runing their own package as they should not need silent installation in this case.
Thanks you both for your answers ... but did you understand why others have this smartscreen problem ? Which have already been fixed for the official use case.
While the client should be perfectly functional, we are not ready to provide full support for clients running outside of the official distribution mechanisms yet. Feel free to file an Issue, but know that it may get lower prioritization.
If it's a real bug then this issue may have a higher priority. Maybe at least bring more documentation so you can fix it yourself if the problem came from your environnement. agowa338 and Jarrett Smith (@jarrettgsmith), can you help me understand what happens on your use case ? You really try official winget realese without tweeks ?
Can you try with "winget install --verbose-logs ..." and look what happens in the last log from ... \ AppData \ Local \ Packages \ Microsoft.DesktopAppInstaller_8wekyb3d8bbwe \ LocalState \ DiagOutputDir ?
You should see two lines "[CORE] Started applying motw to C:... with zone: X". The first one is from the initial download ... X is 3 (internet zone). To be on the safe side, imagine a security breach (even from your internal setup) where you get the wrong file with invalid sha256 then if for any reason this file is not removed from your file system (which winget do immediatly in this case, if I remember correclty) and get run by something else ... smartscreen can save your ass. But if you disable it or have problems during validation process, then you have to confirm you run it at your own risk thus you get the security warning. I never see the second one but I guess the zone X is 2, otherwise this mean somehting is broken with the source trusted level or you do not use the official repository. By doing this, I think winget rely on your configuration which should not require smartscreen as your file is now identified as coming from a trusted zone. Actually, this is more or less the expected behaviour from agowa338 and is exactly what is implement with trusted source (official repository) as the file even don't go through an anti-virus validation (at least not from winget itself).
Also to stay on topic, my expectation as a user of winget-cli would be that files it pulls are already "prechecked" and because of the contained sha256sum don't depend on SmartScreen and that winget-cli just removes the ZoneIdentifier (unblocks the file) if the sha256sum (InstallerSha256 from within the yaml file within the winget-pkgs repo) matches the expected one.
This would also cover non signed executables and extend the safety warranty to them as well as allowing for Winget to work with internal reports.
Basically outsourcing the scanning of the executable to the repository server (this could even be done within the pipeline when a new merge request is submitted)...
When the security window pop up, keep it open and go check which zone your file have. When this happen you already pass all the security measure implemented by winget. One way to know the zone identifier is with a powersheel command "Get-Content your_file.type -Stream Zone.Identifier". The installer is located in ... \ AppData \ Local \ Packages \ Microsoft.DesktopAppInstaller_8wekyb3d8bbwe \ TempState \ WinGet.
[ZoneTransfer]
ZoneId=X
Maybe someone can confirm this path is the acutal installer winget run ?
Finaly in which zone are you ?
It looks like all reports talk about normal online installation from trusted source. If they don't, I clearly want to know how to implement my own repository and change the source ^^
Maybe Windows now require smartscreen even from a trusted zone (level 2) ?
This option can be configured from advance setting of the zone as you can see in this thread, but the option is not visible in intranet neither in trusted and I cannot tell if Windows remove it from level 1 and 2 as I did not check before I update.
You can also change this with a GPO to configure internet settings and I also check my registry under HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Zones about those keys (Enabled: [1806=0] - This setting enables the Launching of Applications and Unsafe Files, in the specific zone) as I was not able to (at least) read the configuration from the graphical interface. So I guess someone can mess with this option even on Zone 1 and 2 but as a common user you will never now it as it's not visible in your zone settings.
May a GPO expert confirm or test if it really change the zone 1/2 behaviour ?
Demitrius Nelon (@denelon), I hope this will helps the engineering team, and the security team. If the intent is to have a silent install with a deterministic behaviour then, sadly, it looks like winget can't rely on the zone identifier as some GPO may change it (except if I misunderstand something). Maybe agowa338 and Jarrett Smith (@jarrettgsmith) are in this case, can't tell you but I imagine this will happen if a GPO can change this behaviour. Otherwise may I suggest an entry in a future faq like "Why did I get a security warning while I wanted a silent install" ? Note I did not had this exact case but I'm sure a clear answer explaining the intended behaviour and how winget seculry install things by default may benefit users in many cases. Not sure if it's woth mentionning the workaround with a local env variable but if it prevent people from changing the zone 3 settings ...
Moreover, I think the added anti-virus check is nice because winget don't rely on the anti-virus setting as some people may disable permanent scan to gain some performance. For the same reason, I think that winget can't rely on the zone identifier to bypass smartscreen (it's a setting which should be enforced just like the antivirus which is enforced in the other case).
Please remember I suppose a GPO can change this security feature in windows. For sure this will not help my use case as I don't want to use the official repository but this can help in any case, mainly if someone change the source code itself (which may be my next move after setting up an internal repo) or the settings to be more paranoid about local share which contain executable and may be considered as Intranet Zone automatically (just a supposition but somehting I must try in my env : prevent execution from intranet share or ask for confirmation just like internet zone). If winget is the one installer/executable source of trust, this may even be recommended or by default in the future.
I think it's also worth mentionning the lack of a signature (as describe earlier to Easton Pillay (@jedieaston)). Somemone may also imagine a case where the executable is patched and the trusted source get change to something else, basically, trusting a string in a executable does make no sense to me, it should be configurable (actually it is if you patch your binary) or not trusted at all. What's nice with signature is that you already have a chain of trust and you can rely on it being already installed securly in your operating system which mays not require internet except if you want higher security with revocation and so (OCSP ? it's not my confort area). You can still add your own certificate in the store but winget can also bundle its own certificate and also perform its own binary signature check. Actually I don't know if Windows enforce digital signature on executable to prevent unwanted execution on patched binary and if it's the case, the string in the binary should be safe then. I also think the only way to make it safe as the binary self check is insecure by design is to rely on both solution with an internal certificate to enforce the repository trusted installers and an external one to enforce winget binary integrity just like when you initialy download it from an htpps trusted source.
The idea is to sign installer and not manifests so the source is not taken in consideration and people can do whatever they want if they use the original installer trusted by the official winget release. I guess this solution will both meet security design and users expectations. On top of that, each source must be implemented in https so an administrator can add its own repository and benefit from the https trust of manifests from the source. The administrator just need to add the source.
This is how I solve my use case with both Winget and Chocolatey software but really it would not have been possible to realize this software without Winget! Thanks a lot!
As I did not test it from scratch again, you may find some problems but I think it should work. My address is in the source code license. The hard part is the internal website setup which must point to the installers directory. Except that, just follow the readme, it's very easy to setup. chocowin.0.1.zip
Hope this helps and maybe we can take some idea there and bring them into real cpp code. Until then, if some peoples are interested we can still open a repo for this small script.
Sorry if for any reason I should not have sent it there. I just want to give back in case someone find it helpful.
Having this same issue with Winget v1.0.11451 on build 21390. It worked fine previously, but now unless I have the env variable added, I get stuck with a Zone Identifier issue, says that my internet security settings have prevented the application from running and I've made no changes to any of those settings, nor has any program installed (I reset IE settings to make sure), or any GPOs as my machine is not managed and no policies are defined.
Only just noticed when I tried to do a winget upgrade --all, and then when that failed, tried to do a single application.
Do you have SmartScreen's "Check apps and files" enabled on your machine?
Is your machine domain/MDM joined (this may not matter, but if your organization is pushing down policies that change your internet zone settings it could be an issue).
I did have Smartscreen enabled. As mentioned in my comment, my machine is not managed at all, no policies were defined.
However I have taken the Windows 11 Dev Insider Channel update and the issue seems to have been alleviated, I just attempted winget install git and a winget upgrade --all and things are working again. As with the previous commentors, while on that build, turning off Zone Identifier checks fixed the issue, but I no longer need the workaround now on 22000.65.
Activity
jedieaston commentedon Mar 15, 2021
Is SmartScreen enabled on the target machine? If it is disabled, the prompts appear under certain scenarios regardless of what flags are passed to winget (since it's Windows putting them up, not winget).
#703 has some discussion of this issue, but the problem should have been fixed in the last release of winget (which you have)...
jarrettgsmith commentedon Mar 16, 2021
So I checked SmartScreen settings on all systems. They were all turned off but a few of them had a warning link to the top right of the toggle button that I clicked which popup up a security dialog asking me to confirm. Once I did this I clearly confirmed
winget isntall git.git --silentworked on one computer. Then I did the same check on another computer and it didnt fix the issue. I noticed the user interface for this section was slightly different on each computer - so I updated everything to 20H2.So now I have all systems up to date but 1 computer still forces the popup. Here is an image of the security toggles and the shell output.
As well I just tried turning off the toggles for Edge and the MS Store Apps but still have same issue.
Thanks for you help.
jedieaston commentedon Mar 16, 2021
On that system, you need to check "Check apps and files" for the security warning to go away. If Windows checks the file against SmartScreen, it is sure enough that the file isn't malware so it doesn't have to ask you.
Edit: it's worth noting that if you are doing this on several machines, these settings can be centrally configured through GPO/MDM: https://docs.microsoft.com/en-us/windows/security/threat-protection/microsoft-defender-smartscreen/microsoft-defender-smartscreen-available-settings#group-policy-settings
jarrettgsmith commentedon Mar 16, 2021
Oh wow you are correct. However on the other two systems that checkbox is off. Any ideas what the difference might be? Will check next what happens when I normalize everything.
As well thanks for the tip - yes this is scaling up to 15 new systems so I really appreciate the pointer. Thanks for making winget just found out about it a few days ago and Im really excited to tell our community about it.
Edit: I guess you already mentioned the flags passed along to winget aren't necessarily in sync with the user interface. The solution therefore would be to turn them off and on?
jedieaston commentedon Mar 16, 2021
"Check apps and files" means that Windows sends a signature from the file to Microsoft to see if it is malicious before opening the file, and in 20H2 they broke this out from the other SmartScreen settings to make it more clear what is going on I think (although someone may know more about it than I do).
The flags passed to winget don't control SmartScreen, it's a different application (and if passing silent to winget caused SmartScreen settings to change that would break a lot of stuff in corporate environments). The settings in the Defender control panel should be what is being applied (and will be greyed out if you use GPO instead).
denelon commentedon Apr 1, 2021
Easton Pillay (@jedieaston) you seem to be familiar with Group Policy. Would you mind taking a look at some of the policies for the Windows Package Manager? #154
I think we're going to rename them to be more generic "App Installer" since that is what we ship in, so "Windows Package Manager" might become "App Installer" for the policy titles, but the descriptions are pretty close to what we're thinking.
denelon commentedon Apr 16, 2021
Jarrett Smith (@jarrettgsmith) we haven't determined the best path forward for remote execution. Many installers require UAC or have some sort of dialog box. I think remote scenarios may require some additional work in the manifest and the client. I don't know if anybody has created an Issue to address remote scenarios off the top of my head.
jarrettgsmith commentedon Apr 16, 2021
agowa commentedon Jun 3, 2021
Just for the record, going into internet options and allowing unsafe files to execute is currently the only way?

jedieaston commentedon Jun 3, 2021
If SmartScreen is disabled or otherwise unavailable on the system, yes. But you should enable SmartScreen, it's safer.
agowa commentedon Jun 4, 2021
Easton Pillay (@jedieaston): I already disabled SmartScreen, that alone didn't work around this problem...
10 remaining items
fabienr commentedon Jun 14, 2021
Thanks Demitrius Nelon (@denelon), I was reading more comments and more code in the meanwhile. Looks like I will not sleep without a solution (no, realy this is my last comment today). I'm loocking further now. Thus I read the https://github.com/microsoft/winget-cli/releases/tag/v0.2.3162-preview.
I move my internal website to zone 2 (trusted) instead of 1 (internal) sorry if I'm confused with 1/2/3 ...
When I download it from edge there is no problem but in fact the file have no zone at all.
Wherase the file downloaded from winget (which I delete myself before runing install) have zone 3
So it looks like winget did not identify my website correcltly as the flag InstallerTrusted is not set ?
if (WI_IsFlagSet(context.GetFlags(), Execution::ContextFlag::InstallerTrusted)) { Utility::ApplyMotwIfApplicable(context.Get<Execution::Data::InstallerPath>(), URLZONE_TRUSTED); } else if (WI_IsFlagSet(context.GetFlags(), Execution::ContextFlag::InstallerHashMatched)) { const auto& installer = context.Get<Execution::Data::Installer>(); HRESULT hr = Utility::ApplyMotwUsingIAttachmentExecuteIfApplicable(context.Get<Execution::Data::InstallerPath>(), installer.value().Url);I have to further read the source code to understand how the flag is set, should't it be set based on internet setting ?
if (context.Contains(Execution::Data::PackageVersion) && context.Get<Execution::Data::PackageVersion>()->GetSource() != nullptr && WI_IsFlagSet(context.Get<Execution::Data::PackageVersion>()->GetSource()->GetDetails().TrustLevel, SourceTrustLevel::Trusted)) { context.SetFlags(Execution::ContextFlag::InstallerTrusted); }Then I do not understand what ApplyMotwUsingIAttachmentExecuteIfApplicable is doing but I guess it changed nothing to the zone as there is no further result for ApplyMotwIfApplicable neither for IZoneIdentifier. Should I do something to refresh / apply my internet settings ? Actually what is a trusted zone from winget point of view ?
fabienr commentedon Jun 15, 2021
Just to clarify, I'm seeing the same security warning as others comments and I'm not able to silently install packages with winget. This is not related to any specific manifest but rather to the way I mirror the winget repository and internalise the deployment.
After reading more code, even if I'm not used to cpp. The source check is not checking the installer url but rather the source from which the manifest came from.
I'm using "-m" to install from a local manifest
In this case, I guess GetSource() return nullprt as the manifest did not came from any source. Am I just ?
If I try to implement/use/configure an internal source repository (is there any implementation I can use ?)
Only "https://winget.azureedge.net/cache" and "https://winget.azureedge.net/msstore" are trusted by winget. Right ?
As smartscreen is disable (I have to try with this feature enable), or, maybe, if I don't have internet access
The Attachment Execution Service which trigger anti virus and determine ZoneIdentifier do not report any error but still consider the executable as comming from Internet thus the Zone.Identifier does not change. I'm not sure if this step should change the Zone.Identifier but at the end Windows security feature prevent installer execution as it was not able to verify its footprint with smartscreen. Is it normal the Zone.Identifier does not change even after a successfull anti-virus validation ?
Actually there is no easy solution for my use case which is standalone offline deployment.
The second point may be the easiest one but this depends on your security policy (which I understand but still I think you prevent/ignore Administrator settings).
For sure there is other solution, what do you think should be done even if standalone offline installation is not a priority feature ?
I'm going to to workaround this issue with $env:SEE_MASK_NOZONECHECKS=1 to make progress until there is a proper solution.
denelon commentedon Jun 15, 2021
Fabien Romano (@fabienr)
jedieaston commentedon Jun 15, 2021
This shouldn't be too hard to add on in a REST source implementation, I was thinking about a similar use case but am waiting for a way to deploy the sample restsource so I can mess with it. The redistribution rights internally shouldn't be a problem, SCCM does it all of the time. You just can't (or shouldn't) make the mirror public without permission from the copyright holders.
fabienr commentedon Jun 15, 2021
Demitrius Nelon (@denelon)
I guive a quick look on REST API. Looks promising. I have no knowledge about C#, Azure, Visual Studio and all those full feature envs but it looks like the database layer depends on Cosmos DB which depend on Azure thus online then I will not be able to use it internaly even if I manage to run it with Mono. I saw you and Easton Pillay (@jedieaston) talk about the database layer which could be abstracted and allow, as exemple, a mongodb backend.
In all case, for standalone / offline deployment, winget-cli should provide a solution to trust an other repository, or apply administrator settings to identify known url installer or just relax the Zone.Identifier (zone 1 or 2 or just unblock the file, remove the identifier).
What I have done is easy scripting and it can even be easier without the need to host installers on a local website (which also need a valid https certificate if I did not mess things during my test). Initially I wanted to bring all of these into an usb hard drive with simple powershell scripts, one to install winget and others to install a list of manifest based on profile you define when you setup your standalone folder with my python script. Then you may also be able to share this folder with correct persmission and run those script to deploy and update packages on a regular basis. This can be seen as a poc for a feature which may be added to winget, let's say a new command named clone. Unfortunatly this is not possible as installer url must be http and this will also break the winget security design by allowing an untrusted hard drive which is not safe.
Easton Pillay (@jedieaston)
What is your use case ?
Initially I started with chocolatey but this still is a lot of handwork with the free version as it's almost impossible to parse and extract the installer to internalise it. With winget it's easy to make a script and I have something which will work if I manage to bring all piece together (even a standalone hard drive if I manage to run a portable web server and make things work without https). Note that for now I'm relying on chocolatey which run winget internally but this can easily be changed to be standalone with simple powersheel script, I just choose to use chocolatey to deploy my configuration and tweeks with powersheel and also benefit from the time I spent learning it as it also could help me in some scenario.
But remember, if you internalise installer and repository, it's at your own risk and, actually, there is a reason why it's not so easy to implement as it's inherently insecure. As an exemple, the application should check the sha256 with a signature (or the whole manifest but then you cannot tweek it which is also a need in some case and maybe if someday we can also do post-install configuration) from the official repository to ensure the original installer and your repository was not altered both, even in your local repository which may be far less safe than the actual security measure implemented by the official repository. For sure if you then want to deploy an unofficial package or an internal application, it looks like this tool is not intended for you but still winget can allow administrator to configure that. Note this does not prevent testers from runing their own package as they should not need silent installation in this case.
Thanks you both for your answers ... but did you understand why others have this smartscreen problem ? Which have already been fixed for the official use case.
If it's a real bug then this issue may have a higher priority. Maybe at least bring more documentation so you can fix it yourself if the problem came from your environnement.
agowa338 and Jarrett Smith (@jarrettgsmith), can you help me understand what happens on your use case ? You really try official winget realese without tweeks ?
Can you try with "winget install --verbose-logs ..." and look what happens in the last log from ... \ AppData \ Local \ Packages \ Microsoft.DesktopAppInstaller_8wekyb3d8bbwe \ LocalState \ DiagOutputDir ?
You should see two lines "[CORE] Started applying motw to C:... with zone: X". The first one is from the initial download ... X is 3 (internet zone). To be on the safe side, imagine a security breach (even from your internal setup) where you get the wrong file with invalid sha256 then if for any reason this file is not removed from your file system (which winget do immediatly in this case, if I remember correclty) and get run by something else ... smartscreen can save your ass. But if you disable it or have problems during validation process, then you have to confirm you run it at your own risk thus you get the security warning. I never see the second one but I guess the zone X is 2, otherwise this mean somehting is broken with the source trusted level or you do not use the official repository. By doing this, I think winget rely on your configuration which should not require smartscreen as your file is now identified as coming from a trusted zone. Actually, this is more or less the expected behaviour from agowa338 and is exactly what is implement with trusted source (official repository) as the file even don't go through an anti-virus validation (at least not from winget itself).
When the security window pop up, keep it open and go check which zone your file have. When this happen you already pass all the security measure implemented by winget. One way to know the zone identifier is with a powersheel command "Get-Content your_file.type -Stream Zone.Identifier". The installer is located in ... \ AppData \ Local \ Packages \ Microsoft.DesktopAppInstaller_8wekyb3d8bbwe \ TempState \ WinGet.
Maybe someone can confirm this path is the acutal installer winget run ?
Finaly in which zone are you ?
It looks like all reports talk about normal online installation from trusted source. If they don't, I clearly want to know how to implement my own repository and change the source ^^
Maybe Windows now require smartscreen even from a trusted zone (level 2) ?
This option can be configured from advance setting of the zone as you can see in this thread, but the option is not visible in intranet neither in trusted and I cannot tell if Windows remove it from level 1 and 2 as I did not check before I update.
You can also change this with a GPO to configure internet settings and I also check my registry under HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Zones about those keys (Enabled: [1806=0] - This setting enables the Launching of Applications and Unsafe Files, in the specific zone) as I was not able to (at least) read the configuration from the graphical interface. So I guess someone can mess with this option even on Zone 1 and 2 but as a common user you will never now it as it's not visible in your zone settings.
May a GPO expert confirm or test if it really change the zone 1/2 behaviour ?
Demitrius Nelon (@denelon), I hope this will helps the engineering team, and the security team. If the intent is to have a silent install with a deterministic behaviour then, sadly, it looks like winget can't rely on the zone identifier as some GPO may change it (except if I misunderstand something). Maybe agowa338 and Jarrett Smith (@jarrettgsmith) are in this case, can't tell you but I imagine this will happen if a GPO can change this behaviour. Otherwise may I suggest an entry in a future faq like "Why did I get a security warning while I wanted a silent install" ? Note I did not had this exact case but I'm sure a clear answer explaining the intended behaviour and how winget seculry install things by default may benefit users in many cases. Not sure if it's woth mentionning the workaround with a local env variable but if it prevent people from changing the zone 3 settings ...
Moreover, I think the added anti-virus check is nice because winget don't rely on the anti-virus setting as some people may disable permanent scan to gain some performance. For the same reason, I think that winget can't rely on the zone identifier to bypass smartscreen (it's a setting which should be enforced just like the antivirus which is enforced in the other case).
Please remember I suppose a GPO can change this security feature in windows. For sure this will not help my use case as I don't want to use the official repository but this can help in any case, mainly if someone change the source code itself (which may be my next move after setting up an internal repo) or the settings to be more paranoid about local share which contain executable and may be considered as Intranet Zone automatically (just a supposition but somehting I must try in my env : prevent execution from intranet share or ask for confirmation just like internet zone). If winget is the one installer/executable source of trust, this may even be recommended or by default in the future.
I think it's also worth mentionning the lack of a signature (as describe earlier to Easton Pillay (@jedieaston)). Somemone may also imagine a case where the executable is patched and the trusted source get change to something else, basically, trusting a string in a executable does make no sense to me, it should be configurable (actually it is if you patch your binary) or not trusted at all. What's nice with signature is that you already have a chain of trust and you can rely on it being already installed securly in your operating system which mays not require internet except if you want higher security with revocation and so (OCSP ? it's not my confort area). You can still add your own certificate in the store but winget can also bundle its own certificate and also perform its own binary signature check. Actually I don't know if Windows enforce digital signature on executable to prevent unwanted execution on patched binary and if it's the case, the string in the binary should be safe then. I also think the only way to make it safe as the binary self check is insecure by design is to rely on both solution with an internal certificate to enforce the repository trusted installers and an external one to enforce winget binary integrity just like when you initialy download it from an htpps trusted source.
The idea is to sign installer and not manifests so the source is not taken in consideration and people can do whatever they want if they use the original installer trusted by the official winget release. I guess this solution will both meet security design and users expectations. On top of that, each source must be implemented in https so an administrator can add its own repository and benefit from the https trust of manifests from the source. The administrator just need to add the source.
Regarding the workaround, thanks to Easton Pillay (@jedieaston) and Sven Mauch (@svenmauch) to mention it. I may have spent hours to discover SEE_MASK_NOZONECHECKS and the initial issue is closed.
fabienr commentedon Jun 20, 2021
Demitrius Nelon (@denelon), Easton Pillay (@jedieaston)
This is how I solve my use case with both Winget and Chocolatey software but really it would not have been possible to realize this software without Winget! Thanks a lot!
As I did not test it from scratch again, you may find some problems but I think it should work. My address is in the source code license. The hard part is the internal website setup which must point to the installers directory. Except that, just follow the readme, it's very easy to setup.
chocowin.0.1.zip
Hope this helps and maybe we can take some idea there and bring them into real cpp code. Until then, if some peoples are interested we can still open a repo for this small script.
Sorry if for any reason I should not have sent it there. I just want to give back in case someone find it helpful.
ShadowEO commentedon Jun 29, 2021
Having this same issue with Winget v1.0.11451 on build 21390. It worked fine previously, but now unless I have the env variable added, I get stuck with a Zone Identifier issue, says that my internet security settings have prevented the application from running and I've made no changes to any of those settings, nor has any program installed (I reset IE settings to make sure), or any GPOs as my machine is not managed and no policies are defined.
Only just noticed when I tried to do a winget upgrade --all, and then when that failed, tried to do a single application.
jedieaston commentedon Jun 29, 2021
ShadowEO (@ShadowEO)
Two questions:
ShadowEO commentedon Jul 9, 2021
I did have Smartscreen enabled. As mentioned in my comment, my machine is not managed at all, no policies were defined.
However I have taken the Windows 11 Dev Insider Channel update and the issue seems to have been alleviated, I just attempted
winget install gitand awinget upgrade --alland things are working again. As with the previous commentors, while on that build, turning off Zone Identifier checks fixed the issue, but I no longer need the workaround now on 22000.65.