473 points · by phoe-krk · 6y ago · 191 comments
This isn't some MIDI parser logic, it's an entire JS interpreter that can parse DOM elements! How in Earth did this even get pushed out to a release? Did we learn nothing since the last time [1]?
1: https://bugs.chromium.org/p/project-zero/issues/detail?id=12...
Executing code written in any language -- dynamic, static, compiled, interpreted -- would be problematic here.
> That service loads the low level antivirus engine, and analyzes untrusted data received from sources like the filesystem minifilter or intercepted network traffic.
Forget JS. Do not load or execute code from untrusted sources in an unsandboxed environment with system permissions. This is about capabilities, not syntax. If your main takeaway is, "they should have used a C interpreter instead", then you have entirely missed the point.
But how many C/C++ engineers would think to design a system that runs a min interpreted code, vs JS ones? The take isn’t as bad as you think.
I think this makes it worse.
What reason is there to even have such an interpreter in a highly privileged process?
And BTW, this is why WebAssembly runtime on the server is a big deal. Being able to painlessly run any untrusted code from "nonsafe language" in a sandboxed environment.
Also, if you read it correctly, Avast is running "wild" Javascript in a custom privileged VM (potentially written in C++)
Contrast this with tailor-made, slim and well tested C++ code. And yes, I do expect security companies to have well-written and well-tested code.
Serious question, what are reasons to use JS in non-web contexts, apart from developer familiarity?
I take it you're not a big fan of JS? That's a lot like saying your not a fan of hammers. Maybe you aren't good at using them, maybe the noise scares you; maybe you think hammer wielders are all idiots and the only smart people are shovelers. It's a tool, it works better in some situation, worse in other.
Low effort <insert language here> developers are everywhere. Lol. Please just stop. Any language is a bad language if used poorly. Literally, JS is just as bad as C++ in the hands of the incompetent.
AvastSvc.exe is not the place where you need programming 'at scale'.
Said who?
> You can't have an entire industry push this terrible ecosystem, then expect security companies to miss out on the fun.
I would expect most security experts to push you to use JavaScript instead of C++, since the former will protect you from a number of rather common security issues in the latter…
> Locating and hiring C++ engineers at a scale is something that has become very, very difficult.
Is it really that hard? Here, I can help: I know C++, and I'll be graduating soon. Hire me ;)
Even if you did all that, odds are that you still don't know C++.
Even worse, sometimes the requirements go even farther and require the AV software to be third-party - OS built-in solutions don't count.
At this point, the only safe solution is running proper whitelisting to make sure that only authorized binaries get to run and to keep those binaries up-to-date and, if possible, sanboxed.
If you have such a setup and then you have to install AV like this because of security-theatre, you're making your security much, much worse (because in order to run AV, you have to whitelist it and because AV is apparently written to quality standards that allow running arbitrary user-supplied JS as SYSTEM)
I recently updated my Windows app. VirusTotal showed 14 AV products detected my program as malware, when it clearly wasn't. I tried to report the false positives, but the vendors had terrible and inconsistent ways to do this (or even none for some). Even Microsoft's website didn't work when I tried to upload the program ("upload failed - please try again later").
I searched on the internet, and at least I found a workaround which was to recompile a library I used. This fortunately reduced the false positives down to a few products I hadn't heard of.
At this point, it's very hard to trust AV products with anything.
A program specifically designed to detect many forms of malware and prevent them from infecting computers, as well as cleaning computers that have already been infected.
A program that monitors a computer or network to identify all major types of malware and prevent or contain malware incidents.
That's not a thing.
Not so much. I'm required to run AV software on production Linux systems. All it does is write opinions to a log.
Insofar as the only reason we run it is checkbox-compliance, I'm fine with it being useless - certainly not asking for some kernel module or something that could actually block access. But I do find it funny.
Observations:
- I am not sure this is 'full' javascript engine. I am thinking more inline with static-eval [0]
Example 1: Date.now() returns 'Exception: undefined'
Example 2: console.log([1, 2, 3].map(function(x) { return x; })) returns 'Exception: function(x) { return x; }'
- I couldn't manage to access DOM document.write("<h1 id='x'>html</h1><script>console.log(document.getElementById('x'));</script>");
returns empty
- After reversing DLL little bit, seems like it is used as unpacker ( also it has VBA support )
Still can be some vulnerabilities, but saying running full Javascript/DOM implementation is 100% wrong
I think it's only became like that after the built-in malware detection of Windows 10 became good enough so the antivirus ventors started adding "features" to make themselves stand out and look good on Enterprise comparison charts.
Thinking back on the Windows XP days... You'd be in actual danger if you didn't use one.
[1] https://arstechnica.com/information-technology/2017/05/windo...
https://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=Eset
But from way back it's been RCE prone: https://support.eset.com/en/news325-eset-customer-advisory-v...
Symantec broke Chrome on multiple machines for me.
>The Google researchers found that MsMpEngine contains a component called NScript that analyses any filesystem or network activity that looks like JavaScript. NScript isn't sandboxed and runs at a very high privilege level, and it's used to evaluate untrusted code by default on almost every modern Windows system
Every antivirus is bad.
[1] https://arstechnica.com/information-technology/2017/05/windo...
https://twitter.com/avast_antivirus/status/12376853435807539...
It contains a link to Avast's Coordinated Vuln Disclosure site: https://www.avast.com/coordinated-vulnerability-disclosure and this has a link to Avast PGP key that's served via unencrypted HTTP: http://virfile.avast.com/viruslab/avast-bugs-pgp-key.txt Not only that, the key is a weak 1024 bit DSA key :(
1) https://mobile.twitter.com/buherator/status/1237115773409206...
2) https://www.virustotal.com/gui/file/d0e7e0e0287cd5a6ee36c745...
Have you seen cable TV in the past five years? It's gone so downhill. Half of the content is still in 480p, awkwardly stretched to wide-screen. Commercial breaks seem like they're twice as frequent as they used to be. Shows being aired have drifted even further into reruns-and-reality-TV territory. Even the content of the ads has shifted somewhat, from recognizable brands to injury attorneys who look like they filmed the ad themselves.
You can see the money being drained from the husk of an industry, and you can see the increased desperation as they try to scrape together what money they still can. The same thing is happening with antivirus software.
Another thing to think about is that tons of features that were never added before, are in the products now. Basically being pushed by management because more features = more sales, even if it ends up bloating the product. I remember a few years ago when we were acquired and had to switch AV vendors to McAfee, it made our oldest group of hardware basically unusable (and these were basically kiosk-type machines). The application we were using required IE so we couldn't replace them with Linux machines either.
Through instead of sloppy I would say it's often more on the line of misguided about what is secure and _overconfident_ about their own skill to write code without security vulnerabilities. And if the are no vulnerabilities no sandboxing is needed right (sarcasm).
Through there where and hopefully still are exceptions to this. But don't ask me which ones because I haven't been on Windows for a long time.
Do you have any proof for that or you just like bullshtting people so you appear knowledgable?
You know what, I don't even care if this is made up, it's a great story anyway. It would be a great plot for a movie.
Ivan Vladimirovich is a Soviet computer hacker who creates computer viruses on behalf of AntivirusCorp. One day, he gets a mission that will come to change his life forever...
However as the README says, this is a custom built implementation, built by a company who believes running a JS engine with SYSTEM privileges is a good idea. This means that there are probably exploits available and those do get full access to the system as the highest privileged user.
"In almost 10 years, Sciter UI engine has become the secret weapon of success for some of the most prominent antivirus products on the market: Norton Antivirus and Internet Security, Comodo Internet Security, ESET Antivirus, BitDefender Antivirus, and others. The use of HTML/CSS has allowed their UI to stay in touch with modern GUI trends throughout all these years, and will continue to well into the future.
Sciter Engine is a single, compact DLL of 5+ Mb in size. Application using it are 10+ times smaller than the ones built with Electron or Qt. And size of the distribution matters, one of main Sciter’s customers discovered “golden 40 seconds” rule: for the user, to buy a product, it should not take more than 40 seconds from the click on “download” button to the UI to appear on screen."
---
As mentioned by others, this would be separate from the JavaScript VM mentioned in the OP and would not run as a privileged account (it would just be the UI people interact with).
Is this another case of a metric becoming a target and thus no longer useful as a metric? The quality of software should be how well it performs its intended purpose, not by the conversion rate of the user funnel.
egui.exe is responsible of the UI interacting with the user and seems to not be running at all if the user never brings up the UI.
Considering the memory usage of the UI (~25 MB), looks like they choose to run a very lightweight UI (tray icon only) with eguiProxy.exe (2 MB) then start egui.exe if the user brings up the UI.
To be noted: the memory usage of the UI is almost the same as ekrn.exe which I suppose is the AV engine (1)
[1] I don't run the full suite and some features have been disabled (SSL MITM, web inspection and email inspection)
Seems the original thread is a javascript interpreter for sandboxing and analysing JavaScript in-engine.
UI process doesn't run as system either since there is no gui on that space. you'll find the sciter code in the user processes (tray and app).
Have at it
It lets you call Windows DLL functions from Linux!
https://wiki.winehq.org/Winelib_User%27s_Guide
I've done this myself to exercise a COM DLL from Linux. I had to use Microsofts "OLE/COM Object Viewer" to extract the IDL from the DLL and then compile everything with MIDL and wine-g++, but it worked.
I fail to see how this is a problema and I've been programming with javascript for 8 years...
This is like putting a 2 meter wide thermal exhaust port on your death star. On the off chance someone manages to hit it, game over. This process runs untrusted code so if you can get a file opened on the target computer, or even just get the user to go to a malicious website, you can try to attack this. Once you get some payload running yeah you could use bog standard crimeware to sniff out any credit card details entered, export your saved passwords from your web browser, look for any wallet.dat equivalents and run a keylogger waiting for you to decrypt it, drop some ransomware on the system, etc. This gives full control over the system if you find an exploit to it.
But yeah, this isn't immediately a vulnerability, just a poor design decision and a very juicy target.
Except it's probably more like the second Death Star because it's unfinished and there's a gaping hole in the side of it that you can just fly in.
https://bugs.chromium.org/p/project-zero/issues/detail?id=70...
Now imagine a company's internal JS implementation without all that engineering effort... vulnerabilities will become apparent immediately
It can do everything that the user could do, and the user in this case is SYSTEM. I understand SYSTEM can do everything.
It could install a keylogger, for instance.
Writing your own JS engine and then running it as SYSTEM is terrible engineering and very dangerous. There is no reason for why they have to run it as SYSTEM.
Lastly have we confirmed there's no memory or thread protection in place? Most AV reputable AV companies have strong proprietary sandbox code (especially in the scan engine process) which is on par with virtualization in terms of isolation.
Hence the existence of a number of Windows tools to get TrustedInstaller privileges, some examples listed in this thread:
https://msfn.org/board/topic/181190-how-to-overwrite-dll-fil...
https://docs.microsoft.com/en-us/powershell/module/microsoft...