A customer was developing a Windows service process, and it is important to them that the service keep running on their servers. They wanted to know if there was a way they could prevent users who connect to the server from terminating the service. In particular, they wanted to make sure that the user couldn’t use the anti-malware software to terminate their service, either by mistake or maliciously.
The fact that they made it to asking about anti-malware software tells me that they have already locked down the more obvious access points. For example, they’ve already set the appropriate permissions on their service so that only administrators can Stop the service.
But how do you protect your process from anti-malware software?
The answer, of course, is that you can’t.
Because if you could inoculate yourself against being terminated by anti-malware software, then malware would do it!
Anti-malware software runs with extremely high levels of access to the system. They have components that run in kernel mode, after all. Even if they can’t terminate your process, they can certainly make it so that your process can’t accomplish anything (say, by preventing its threads from being scheduled to execute). And if anti-malware software goes awry, the entire system can be rendered catastrophically broken.
The customer will have to work with the anti-malware software that runs on their server to see if there is a setting or other way to tell the anti-malware software never to terminate their critical service. (Of course, it means that genuine malware might masquerade as their critical service and elude detection. This is a risk assessment trade-off they will have to make.) And if their service runs on client-configured servers, where they don’t control what anti-malware software the client uses, then they’ll have to work with all of the anti-malware software (or at least all the major ones) and see if they can arrange something.¹
But Windows can’t help you. The anti-malware software is more powerful than you.
¹ For example, maybe they digitally sign their service process and give the public key to the anti-malware software, saying, “Please don’t terminate processes signed by this key.” Of course, the real question is whether the anti-malware vendors will accept that.
Unfortunately those reasons are why I can never for any reason or pretext allow antivirus on my machine, to the red line of non-negotiation. The pain of low social credit is limited to what’s on the other side of the socket connection, but a local antivirus is ultimately judging everything I own for intent, with license to kill and the brain of an AI that I didn’t get to train.
I find Xbox consoles fascinating because they are high-stakes Windows devices that lack Windows Defender, and I’ve learned so much and made corresponding PC computing lifestyle changes by asking myself questions. Why is USB keyboard and mouse input tagged as untrusted? Why is Windows Defender absent? What is a security boundary and why should I rely on the ones defined for Windows? Why are full trust applications blocked? What does it really mean to comply with Microsoft Store policies for a software application? How can I get an approximation of S mode without OEM cooperation?
The Add-MpPreference PowerShell function seem to allow for paths & processes to be excluded from Windows Defender scans.
The false-positive problem with antivirus is pretty bad.. I work on a PC game that has about 30-40 Gb (compressed) of resources. It is virtually impossible to download 30+ Gb of compressed (ie. random) bytes without triggering a false-positive hit from someone’s AV.
Heck even the source code .. the git repo is about 5 Gb and doing a git-clone often triggers a false-positive.
I don’t know the solution for this problem.. making it easier to sign stuff, might help? (We are a hobbyist / freeware project, without the resources to sign installers with an EV cert.)
I've wondered about that. Sometimes I think the answer is "Make a new Code Signing root." Once added to the system, the AV should recognize it. This is kind of shifting the target; you still need all the rest of the infrastructure. It's not a lot of money but it's a lot of moving parts. One misuse of your EV root and it will get banned.
git clone should essentially never trip a false positive though; all such should be reported immediately as obviously bad. (scanning engine is pretty broken if it thinks a fragment of malicious code was found in...
That wouldn’t work.
I have a valid, paid-for, IV code-signing certificate which I use to sign my executables. Windows Defender (or is it Smartscreen?) still blocks the file when I share it with a friend saying how they saved his PC. That happens no matter if said executable is written in plain C, C++, or C# and no matter which, if any, system APIs it is using or paths it is accessing. I also had some questionable endpoint protection vendors (looking at you Crowdstrike!) flag them as malware through ML heuristic by listing totally bullshit reasons such as “uses LoadLibrary” (name...