microsoft / WSL

Issues found on WSL
https://docs.microsoft.com/windows/wsl
MIT License
17.17k stars 804 forks source link

wsl.exe fails with "Access is denied" #4920

Open john-vaudin opened 4 years ago

john-vaudin commented 4 years ago

After uninstalling an re-installing Windows Subsystem for Linux I can't install any distro - they all fail with "Access is denied". Even running wsl.exe now fails with "Access is denied".

Your Windows build number: (Type ver at a Windows Command Prompt)

Microsoft Windows [Version 10.0.18362.657]

Steps to reproduce

> wsl.exe Access is denied

Strace and logs attached.

wsl_strace.txt

logs.zip

Amarok24 commented 11 months ago

If anyone are facing this problem, check if you have an App called Windows Subsystem for Linux, if yes, uninstall it and you will get access to wsl2 again.

It was installed here after running wsl --update command.

Thank you!!! That's almost unbelievable, so Microsoft created a conflict between 2 different installations of WSL, one from the command line and the 2nd one from Microsoft Store which appeared automatically without my consent, and that new one was causing this error: Error code: Wsl/Service/CreateInstance/CreateVm/E_ACCESSDENIED

BTW this is the original message from the terminal whenever I launch wsl.exe: Windows Subsystem for Linux is now available in the Microsoft Store! You can upgrade by running 'wsl.exe --update' or by visiting https://aka.ms/wslstorepage Installing WSL from the Microsoft Store will give you the latest WSL updates, faster. For more information please visit https://aka.ms/wslstoreinfo

That's why I've run the update command and then it stopped working. BTW I use WSL2.

Update: to be able to use the new WSL version from Microsoft Store, it didn't help to uninstall the old WSL and install the new one, there were still access denied errors and also no distro could be started (Registry entries broken?), so it was necessary to create a new user in Windows and start from scratch.

codeflorist commented 9 months ago

If anyone are facing this problem, check if you have an App called Windows Subsystem for Linux, if yes, uninstall it and you will get access to wsl2 again.

It was installed here after running wsl --update command.

image

amazing. simply amazing. so wsl.exe --update takes away the possibility to use wsl.exe command line. thus for example completely breaking Docker.

how could this ever have slipped through Microsoft's quality control?! and it's been this way since at least 8 months?!

ZackPlauche commented 3 months ago

For anyone who might still be stuck here, this solution worked for me:

Quoting from that solution: wsl --unregister ubuntu followed by wsl --install fixes the problem for ubuntu atleast

vncntk commented 1 week ago

I suddenly had this problem. I have been working using an administered laptop and have been using WSL Ubuntu for work environment. Laptop went to sleep and when turned on VSCode and cmd couldn't access WSL.

image

image

image

ggcannard commented 1 week ago

@vncntk Seconding this, the exact same thing happened to me today as well. Have not found a solution yet either.

dylancarruthers commented 1 week ago

Same here, seemed to happen after installing the latest Windows Updates:

koleh-tech commented 1 week ago

I have the same problem, but the only update I installed was:

dylancarruthers commented 1 week ago

Fixed after running the following in PowerShell as administrator

Add-MpPreference -AttackSurfaceReductionOnlyExclusions "C:\windows\system32\wsl.exe"

Add-MpPreference -AttackSurfaceReductionOnlyExclusions "C:\Program Files\WSL\wsl.exe"
McRegt commented 1 week ago

Same problem here, have the following updates installed recently:

The Windows Store also results in an exception: image

Adding the Defender rules did not solve the problem for me.

vjanssens commented 1 week ago

Same for me, the solution provided by @dylancarruthers solved the issue when in Administrator mode. Docker Desktop also stopped working because of this and resolved that by:

  1. Stopping Docker Desktop
  2. Run wsl --unregister docker-desktop
  3. Restart Docker Desktop
JakeBroughton commented 1 week ago

I have the same problem, but the only update I installed was:

* 2024-08 Security Intelligence Update for Microsoft Defender Antivirus - KB2267602 (Version 1.417.101.0)

@koleh-tech Defender was the cause for us too with this rule: Block use of copied or impersonated system tools. If you can check your protection history in Defender you might see all the blocked wsl.exe actions.

nariman-zk commented 1 week ago

Same issue here and @dylancarruthers's solution did not solve the issue for me!

bharthijairaman commented 1 week ago

Having the same issue not solved for me either

ms08067 commented 1 week ago

my wsl is broken with "access denied" and it also looks like my traditional virtual machines also fail using vbox after the last windows update. Running Windows 11 10.0.22631 N/A Build 22631

jordanabakerafs commented 1 week ago

This appears to be due to a windows update causing WSL.exe to trigger an attack surface reduction rule in defender for endpoint.

https://learn.microsoft.com/en-us/defender-endpoint/attack-surface-reduction-rules-deployment-test#step-2-understand-the-attack-surface-reduction-rules-reporting-page-in-the-microsoft-defender-portal - Your IT admins can use this report to see if wsl.exe is triggering the rule.

We confirmed this was the issue for our users after installing the latest updates pushed on 08.13.

From here we went into the intune ASR policy and set an exemption for WSL.exe (decent write up here, this is not our page - https://www.nielskok.tech/microsoft-defender-for-endpoint/add-exclusion-in-attack-surface-reduction-microsoft-defender-for-endpoint/)

We tested by running gpupdate /force on impacted devices and rebooting. After reboot, we were able to resume normal ops.

mlcivilengineer commented 4 days ago

Also having this issue and adding these rules to powershell in admin mode still gives me an access denied when trying to launch wsl. Any other alternatives?

jordanabakerafs commented 3 days ago

Also having this issue and adding these rules to powershell in admin mode still gives me an access denied when trying to launch wsl. Any other alternatives?

If you are using intune to manage these devices your intune admin will need to go into the attack surface reduction rules and exempt WSL from there then you can run a group policy update and reboot.

You may be able to look at the windows protection history and see if this is the case:

image

https://github.com/microsoft/WSL/issues/4920#issuecomment-2291906640

himanshu-gupta-ocl commented 2 days ago

Facing this issue with docker desktop. It was working a few days ago but it just stopped working from yesterday. image

No wsl command works for me in powershell Or terminal in admin mode. I get Access is denied error. I've tried reinstalling docker desktop & installing WSL latest 2.3.17 version. Nothing seems to be working. Please help

codeflorist commented 2 days ago

So during not even a full year, Microsoft was able to completely break Docker via WSL two times via bodged updates - creating a massive amount of wasted working hours and annoyance. πŸ‘πŸΌπŸ€‘