- Jul 1, 2017
- 1,396
Don't see the point in all of this when all it takes is one admin or system token to override it all.
If 99 % of time you run your system as standard account, how would downloaded malware you encounter get a chance to grab admin privs / system token? This topic, and more generally SRPs, is one of many prevention strategies for this.Don't see the point in all of this when all it takes is one admin or system token to override it all.
I am afraid that your test is invalid, because the below fact:I tried the following: Default-Deny SRP without Windows Subdirectories rules (actually they are there Unrestricted), removed BAT from DFT.
As standard user, from command prompt, I was able to copy and execute a simple .bat script into each of the directories I identified in the OP. But I could not write to C:\Windows itself for example (as expected). Specifically, I could write and run in all these directories:
C:\Windows\tracing
C:\Windows\Registration\CRMLog
C:\Windows\System32\FxsTmp
C:\Windows\System32\com\dmp
C:\Windows\System32\spool\PRINTERS
C:\Windows\System32\spool\SERVERS
C:\Windows\System32\drivers\color
C:\Windows\System32\Tasks
C:\Windows\SysWOW64\FxsTmp
C:\Windows\SysWOW64\com\dmp
C:\Windows\SysWOW64\Tasks
C:\Windows\Tasks
C:\Windows\Temp
Now, I readded back BAT to DFT and tried same experiment with copying notepad.exe. In this case, I could copy it to all locations but not execute from most (again, from standard user command prompt). Following dirs are the only ones that executed it:
C:\Windows\System32\drivers\color
C:\Windows\System32\Tasks
C:\Windows\SysWOW64\Tasks
C:\Windows\Tasks
C:\Windows\Temp
(Minor note: for some reason notepad.exe did not pop up a window from these directories. It seems to have ran but did not do much. I think it might relate to some other protection I have perhaps - it just paused for a while and quit without any logs in Event Viewer. Only when I call notepad.exe from C:\Windows it actually pops up a window.)
So options appear to be:
- blacklist explicitly all 13 dirs from the OP (and implicitly all their subdirs) - this will make sure that if some file extension is missing from DFT, malware still cannot write it under Windows dir. I guess SRP would be useless against such extension anyway though - they could just write it to some User-Space directory and run it then. So, perhaps this option is uselesst then...?
- blacklist (i.e. SRP disallow rules) explicitly just the 5 directories from the second experiment, not all 13 - that's what you recommend, right? This one will protect DFT extensions (only)
- maybe even blacklist less locations by only blacklisting DIRECT members in the 5 locations (possible in gpedit?) and then figure out other subdirectories of them where direct files but not subdir need to be blacklisted. Your original post for example examined subdirectories even if their higher-up directories were already listed as not-protected. For example, only DIRECT members of
C:\Windows\SysWOW64\Tasks
C:\Windows\SysWOW64\Tasks\Microsoft\Windows\PLA\System
C:\Windows\SysWOW64\Tasks\Microsoft\Windows\RemoteApp and Desktop Connections Update
need to be blacklisted, but not other subdirs of SysWOW64\Tasks.
I edited my previous post. I retested the behavior of BAT and CMD files and it is similar to the behavior of EXE files. So, the ACL execution permission can work also for BAT and CMD files (I was wrong thinking otherwise). But, does not work for CHM, Windows Script Host, PowerShell scripts, etc. That is interesting.Thanks @Andy Ful for explaining the notepad / .bat behavior and apologies for messing up my OP: C:\Windows\System32\drivers\color should have been C:\Windows\System32\spool\drivers\color. I wish I could still edit it :-(
I edited my previous post. I retested the behavior of BAT and CMD files and it is similar to the behavior of EXE files. So, the ACL execution permission can work also for BAT and CMD files (I was wrong thinking otherwise). But, does not work for CHM, Windows Script Host, PowerShell scripts, etc. That is interesting.
SRP in Default Security Level = Disallowed can additionally protect Windows Script Host (also command lines with WSH sponsors wscript.exe and cscript.exe) in blacklisted Windows subfolders.
So, all writable Windows subfolders should be blacklisted for maximum security, even "writable and not executable":
C:\Windows\System32\Com\dmp
C:\Windows\System32\spool\PRINTERS
C:\Windows\System32\spool\SERVERS
C:\Windows\System32\Tasks
C:\Windows\SysWOW64\Tasks
C:\Windows\Tasks
C:\Windows\Temp
C:\Windows\System32\Microsoft\Crypto\RSA\MachineKeys
C:\Windows\System32\spool\drivers\color
C:\Windows\SysWOW64\Tasks\Microsoft\Windows\PLA\System
C:\Windows\System32\Tasks\Microsoft\Windows\RemoteApp and Desktop Connections Update
C:\Windows\SysWOW64\Tasks\Microsoft\Windows\RemoteApp and Desktop Connections Update
.
If the user blocks WSH via policy (like in Hard_Configurator) or via blocked sponsors, then only "writable and executable" Windows subfolders may be blacklisted (skipped first three entries, from the above list).
Your method would be unnecessary restrictive.Thanks for detailed reply! One thing though - some folders don't need protection because when you protect higher level folders then also include all the lower level ones, right? E.g. when I create disallow rule for
C:\Windows\System32\Tasks
there is no need to also then disallow
C:\Windows\System32\Tasks\Microsoft\Windows\RemoteApp and Desktop Connections Update
Or do you specify for your paths above to NOT be recursive? Something like C:\Windows\System32\Tasks\* ?
P.S. Win Pro 1709 (or at least my box) does not have C:\Windows\System32\Microsoft\Crypto\RSA\MachineKeys dir.
Your method would be unnecessary restrictive.
Ha, ha - you caught me.Uh oh! So it may cause system instability then?
I thought that was YOUR method... I am glad I asked! So, to properly do this the way you would, should all those paths end in /* in SRP? E.g. path rule for
C:\Windows\System32\Tasks\*
C:\Windows\System32\Tasks\Microsoft\Windows\RemoteApp and Desktop Connections Update\*
etc.
?
The less restrictive rules would be, those with *.* :
C:\Windows\System32\Tasks\*.*
C:\Windows\System32\Tasks\Microsoft\Windows\RemoteApp and Desktop Connections Update\*.*
No. You would have to use : C:\Windows\System32\Tasks\*.*...
Does protecting
C:\Windows\System32\Tasks\* (same as *.*?)
The number of folder path rules is not important for security if the rules have the common left side, but using *.* (file path with wildcards) is important, and less secure.... if we go with two rules, could some malware with user-privs create a directory under Tasks, then drop something into that dir, and then execute it, since now the subdirectory would not be covered by the 2 rules...
Generally, #3 type rules are more secure for folders that allow making subfolders, then the exploit can make a subfolder, copy the payload to it and execute. This is not the case with the concrete folderWhy exactly is #3 less secure than say #2? Where can malware write / execute under #3 that it could not do under #2?
I was thinking any other subfolder under Tasks, except for the 1 identified are already NON-writable by users? Or is it less secure because of that last-paragraph-scenario in my previous post?
Generally, #3 type rules are more secure for folders that allow making subfolders, then the exploit can make a subfolder, copy the payload to it and execute. This is not the case with the concrete folder
C:\Windows\System32\Tasks, but is true for the folder:
C:\Windows\System32\Tasks\Microsoft\Windows\RemoteApp and Desktop Connections Update
In #1 or #2 the payload will be blocked by SRP, in #3 not.
.Great, thanks for confirming!
So you are talking about the last-paragraph-scenario in my prior post, i.e. "Then again... one potential hole I just thought of but have not tried: if we go with two rules, could some malware with user-privs create a directory under Tasks, then drop something into that dir, and then execute it, since now the subdirectory would not be covered by the 2 rules..."
Now, I noticed in your earlier post here you said: "all writable Windows subfolders should be blacklisted for maximum security, even "writable and not executable""; however your re-tests were only based on what you had considered as Protected folders before. In other words, I think you will find other writable folders as well. My OP is effectively listing all such writable dirs (after I had disregarded all writable subdirs of such dirs, but I understand based on your explanation why those might also be good to include if we plan to sometimes remove ancestor folders).
On my system these are the writable dirs (bolded items are NOT included in your latest list from this post):
C:\Windows\tracing
C:\Windows\Registration\CRMLog
C:\Windows\System32\FxsTmp
C:\Windows\System32\com\dmp
C:\Windows\System32\spool\PRINTERS
C:\Windows\System32\spool\SERVERS
C:\Windows\System32\drivers\color
C:\Windows\System32\Tasks
C:\Windows\SysWOW64\FxsTmp
C:\Windows\SysWOW64\com\dmp
C:\Windows\SysWOW64\Tasks
C:\Windows\Tasks
C:\Windows\Temp
Thank you for a great discussion, Andy. I think I have a much better appreciation of this topic now and feel safer blocking above dirs after learning of your experiences!
One can enhance the protection also for PowerShell scripts and other abused files (CHM, HTA, REG, etc.) by adding Disallowed rules for sponsors (powershell.exe, powershell_ise.exe, hh.exe, mshta.exe, regedit.exe, reg.exe, regedt32.exe, etc.)
Paranoid users should block all sponsors, and delay Windows Updates. Then updating may be done with unblocked sponsors. The blocked sponsors can interfere with updates very rarely. I installed Windows Vista, Windows 7, Windows 8, Windows 8.1, Windows 10, several times with upgrades and hundreds of updates. Only one update in Windows 10 FCU failed (one month ago). I simply unblocked the sponsors, and the update finished successfully.Thank you for a nice summary, Andy!
I know you later said careful users don't have to bother, but for the paranoid of us, would you say hh.exe, mshta.exe, regedit.exe, reg.exe, regedt32.exe are fine to block and will not cause instability (since they are only blocked for NON-admins), right? Any others that come to mind?