Rm -rf / in Windows Subsystem for Linux reveals sharp set of teeth
slightfuture.com
slightfuture.com
Well, I bet, if it blocked these actions, there would have been another blog complaining how the Linux subsystem is just a toy, goes against the Unix tradition of "can shoot yourself in the foot if you really want" etc etc.
And I'd definitely much rather be able to do dangerous things if I want to, than be told that I need to be protected from them. I do appreciate that rm -rf requires "--no-preserve-root" for that extra level of certainty, but the author of the OP should not be surprised at what happened.
And if you prevent unlink() or rmdir() from working on files within /mnt/c or other Windows drives, you would not only break the ability to do normal file management with rm or other Linux tools; you'd also break every application that creates and removes temporary files, or otherwise manages files programmatically. You couldn't, for instance, use "git checkout", because that unlinks files and rmdirs directories present in the current HEAD but not present in the new target to check out.
rm (without --no-preserve-root) specifically checks for an attempt to remove / before it starts recursing. You could potentially improve rm to preserve a few more directories by default; some tools exist to do exactly that, such as safe-rm.
rm's default --preserve-root behavior mostly exists to help catch cases like "rm -rf $VAR/$VAR2", which with VAR and VAR2 unset would turn into "rm -rf /".
(Personally, I'd like to have rm add and default to a --preserve-home option too, to catch things like "rm -rf $HOME/$VAR" or "rm -rf ~/$VAR" or "rm -rf ~ /foo".)
--no-preserve-root seems like a sufficient safeguard here.
This exact thing happened with system32. And deleting a system file somehow seems much more obviously dangerous than entering a command you don't understand. "rm" looks pretty harmless, and someone could come up with a backronym that even makes it seem sensible.
In fact I wonder if this is the reason pasting into console is disabled, or at least hard to figure out, on Windows.
They also got rid of deltree, which is the Windows equivalent of rm -rf, and was abused in a similar way.
I think they definitely don't; instead, they need to learn from it. Mollycoddling them will only encourage such stupidity and help it proliferate. If taking a few seconds to search online for more information is beyond their ability, then they deserve everything that happens to them.
Whether or not users "need" to be protected from stupidity is an opinion of course. But it's in Microsoft's interest to protect their users, and users want to be protected. So who is to say they are wrong to do so?
I find your assertion that the world would be a better place if more people made serious mistakes, really hard to believe. A 10 year old ruining his parents computer might teach him a lesson. But how much does he gain from that lesson, really? And at what cost? Would you personally help distribute malicious advice memes, if you really believe this is a good thing?
cmd /crd /s /q \
This is faster in WindowsInitially it looked to me like a switch called "crd" as argument to the "cmd" command. This would have fooled me into thinking it is harmless. I wouldn't have fallen for "format c:" but I might have fallen for this.
The space between "/c" and "rd" is apparently not necessary. I tested it and it really works.
The level of damage described sounds like it does.
Googling around tells me that good old "deltree" no longer exists, but I would have assumed PowerShell would have some equivalent. If you do such a thing as administrator, won't you expect serious damage?
If the Linux layer allows deleting and replacing in-use files, that's pretty cool and a welcome feature.
If this is just a substitute for deltree I'm not sure I get the point.
An exception to this is memory mapped files as they are not allowed to be deleted that way. Executables are executed in Windows by memory-mapping them; so runnning programs are hard to delete.
- You can't delete the parent directory
- You can't create a new file with the same name
... which makes that flag quite useless.
It would be an interesting (and probably good enough) safety net if they treated /mnt/c the same as / in this case.
That said, the above only saves you if `/` and `/mnt/c` are the same device mounted at two different places - I haven't used the system to know.
:(){ :|:& };:
Based on that sentence, I assumed the command was being executed by a user in the Administrator group
sudo chmod -R a-x /
and post the findings.This begs the question how many other things you can exploit with it to bypass file/system permissions.
I'd consider it a bug/limitation if running as root in the Linux subsystem, because root should be able to do that too.
Nothing actually stopping you from deleting "explorer.exe" from gui/cmd but you have to do some steps in order to take ownership of those files even with admin rights, this includes interacting with the UAC functionality in windows.
Seems that the new linux subsystem bypasses that and unless the guy in the article has already disabled every security measure in windows this is a big deal.
And no I won't consider it a bug, I don't care what root should or should not be able to do the fact that a user can delete critical system files while the OS is running is bad design there is simply no scenario in which you would want or need to do it, not in Windows and not even in Linux.
How would you suggest this could be done?
(Edit: added links correctly)
[0] http://www.bsdnow.tv/episodes/2015_11_23-the_cantrill_strike...
[1] https://github.com/illumos/illumos-gate/blob/5a4ef21a18dfdc6...
You have the same thing in other OSes, hence --no-preserve-root
I now realise that while one may have an rm that takes care of this, one could always get another rm that does not.
I'm very excited about the Subsystem for Linux. It will make Windows a great all-purpose development system. As it is, I have an easier time running must GNU/Linuxy stuff on cygwin than I do on Mac....
Total cake on a windows system.
Anything that requires python libraries outside of the bog standard seems to be a 50/50 tossup on OS X.
The only thing I use regularly that works better on Mac is "Vagrant" 1.8. I have to stay on 1.7.4 on Windows. If you look at their issue tracker, it's clear nobody's caring too much about Windows over there. Of course, with the Subsystem For Linux, I can just run the Linux one on Windows!