Stealthy Linux rootkit found in the wild after going undetected for 2 years
arstechnica.com
arstechnica.com
Krasue is a Linux Remote Access Trojan that has been active since 20 and predominantly targets organizations in Thailand.
Off-topic, but this is the first time I've seen post-1999 year denoted with just two digits without the use of an abbreviating apostrophe.Can anyone give me any more depth on this? Is a typical desktop Linux distro install more likely to be susceptible to attack by a nation-state level actor?
The typical attack vector for any system would be compromising the inbound software. This is really easy to do when people are downloading and installing random programs from websites. This used to be less common, but popular cutting edge tools have popularized it recently "distro packaging is too slow, etc, curl|bash to install"
On linux, most base software comes from the distro repositories. The question there is how hard it would be to compromise these systems (including one of the mirrors). This includes ancillary packaging systems (pip, cpan, gems, conda, etc)
Maybe the "this will be easy" part was that without AV software, there was a greater chance that they could just spin up Metasploit, and wouldn't even have to use one their stockpiled zero-days?
The difficulty level is "recompile with small changes and test that it doesn't match" not "develop a new attack vector"
It really is stupid and pointless against an attacker with even a bare minimum of competence (able to run a software build vs downloading binaries)
Just a reminder that I was originally talking about desktop Linux, and all of the additionally installed attack surface which that entails.
It would seem to me that it does not matter how "technical" a user is, they are still human, and some of the time anyone could fall for a well formed phishing attack. We all get tired, overworked, or click too fast, etc.
Not running AV on a desktop OS and relying on one's own superhuman technical ability seems like the exact type of hubris that would be ripe for attack.
See another user's comment: https://news.ycombinator.com/item?id=38594247
Security is an onion, perfect is the enemy of good, etc...
Why make it easier for the adversaries? While annoying, running EPP on your desktop OS is not exactly neuroscience.
Ideally, it's furnished by the OS provider so that there are fewer parties to trust. I hate to say it, but Microsoft is now teaching by example. MS has factually one of the best-in-class Endpoint Protection agents on the market.
If resources allowed, all other desktop OS providers should follow suit, otherwise they are just shirking responsibility.
Would love other input as I’m not an Ubuntu daily driver anymore.
It turns out 22.04 has ClamAV “provided and supported,” but not installed by default. So it should easily install manually. That’s what I would go with first, as it’s officially supported. An OS vendor supporting a specific AV vendor is a really big deal imho.
If that is not satisfactory by some metric, and this is just my personal and dated opinion… I used to like Eset.
I was naive before, but next time I install desktop Ubuntu, I will install ClamAV immediately.
This means either:
- a 0day, which would require the AV to have a PDF parser better than the standard document viewer, and the ability to sense that this PDF is "weird" -- I would expect AV companies to publish ads "our AV has detected a 0day in XXX"
- a vulnerability was recently discovered in a PDF viewer, and the AV company can push their definitions earlier than the standard "package the fixed version - send to debian-security - let users upgrade" route. This would shorten the attack window by a few hours. Again, I would expect AV companies to boast "we were X hours earlier than the official fix".
Which one is the case? Or is there another option?
Actually, this whole "buggy PDF parser" thing should be solved by application sandboxing -- there is no need that document viewer needs any other access to my system. Unfortunately, Linux is lagging behind. There are some AppArmor experiments with not so great UX, and then there is QubesOS, which is difficult to use. The average Linux desktop is AFAIK almost unsandboxed.
I am now at the limits of my understanding...
I only ran Ubuntu as a desktop daily driver for a year or so, and I'm a muggle, so my understanding is limited. But, is there any real-world data on how often desktop Linux users run the equivalent of:
sudo apt update
sudo apt upgrade
sudo apt dist-upgrade
versus the more automated update systems MacOS or Windows ?I am genuinely curious which ecosystem is more likely to be up to date. In my limited experience, I ran into issues updating on Ubuntu, and have not on MacOS and Windows. It seems like MacOS does it best as most applications come via the App Store, and on Windows that's in the future leaving most apps to take care of their own updates. However, Windows makes up for that a little bit with excellent, and auto-updated EPP, so that's something at least.
In your view, which desktop OS is most likely to be up to date for OS and apps?
> versus the more automated update systems MacOS or Windows
I'm not sure -- it is better with Microsoft Store, but other apps solve updates on their own, with various success. I have little experience with Windows and no with mac OS, so I cannot comment.
It is not a meaningful technical barrier. It's the equivalent of storing a big table of mean things people said in a chat and suggesting this could prevent a capable person from insulting someone. Any moderately competent person can think of a way to communicate without using previously blocked phrases with minimal effort.
The AV databases are known - it is trivial to test against them to ensure a binary won't match.
AV is a crude tool, good only for blocking the most basic of efforts. It has no utility against a nation state.
Are you referring specific'ly to a limitation ClamAV?
I know, because I've been writing small malware toys and it got blasted by both Bitdefender and ESET.
Ransomware runs just fine on corporate computers with the latest and greatest "antivirus" software.
I really lost hope some 10 years ago, when i saw that i have to manually remove malware from memory sticks, because macaffe was clueless. After more than a year they released an update that will detect and remove the malware (it was a virus speading through autorun.inf with exe names which did not have any sense like jhghjjj.exe)
https://www.cybereason.com/blog/cybereason-named-a-leader-in...
Things have changed in the last 10 years. Long gone are the days of only using signature databases.
https://attackevals.mitre-engenuity.org/results/enterprise?v...
IMO if you're worried about the NSA, I assume they have access to root certificates and your package manager that uses TLS would be vulnerable. Wouldn't have to compromise any system or mirror to do so.
Still, I feel like distro packages are really secured compared to stuff you install via pip/npm/... as I don't believe they do anything beyond protecting downloads with TLS.
Since I am very much a Linux & infosec muggle, please indulge me with these possibly dumb questions:
What are the mitigations for the lack of provenance in pip/npm?
Does properly configured SELinux do enough? Or is the fact that many of these packages use 80/443 negate that? Or is the fact that a pip/npm package could be comprised after install, during update the main problem?
I always think of that left-pad NPM drama, could that single dev have comprised thousands of systems by changing his update to something much more nefarious, instead of just deleting the package?
Again, sorry if these are dumb questions.
The thing that "protects" you is package locking, where unless you explicitly update your packages, you'll stay on an uncomprimised version (this broke with leftpad, as every available version was deleted). Locking has the downside that you don't get security updates for your software, which might be even more harmful tho.
Say it was Ubuntu Desktop… would installing the supported EPP, ClamAV help in some regard? It would, right? Should this be a Tell HN type thing?
Maybe ClamAV being installed by default, like UFW, is the real (partial) solution?
To protect a system, the only really reasonable approach is to not run code/binaries you don't trust. Once malicious software capable of writing files in ~, it's too late (those new sandboxing solutions are also not really solving this, as their interfaces to access files suck, so everyone continues to use the posix api with full access).
The only "Linux system" that can be considered secure in that regard is Android, as you don't have software that tries to execute "random" stuff in ~ and Apps tend to get away with using SQLite (not exposed to the user) over complex filesystem structures. Obv. you used to be able to access ~ rw, so malware could still upload/encrypt your Data, but most Users only have Pictures there (as other data was only stored in app-only storage [/data/data/<id>/] that couldn't be accessed by anyone else). Now you don't even have access to that, so malware is even more limited (but obv. legitimate software also suffered from that, for example WhatsApp used to store it's data there in ~/WhatsApp/ so you could simply access media sent/received on chat but now its far more hidden).
Debian-derived systems use GPG signing so that wouldn't be enough, there's no central authority in the first place. There are hundreds of Debian developers, and most likely they could find one with poor opsec (or straight-up send a National Security Letter), but they would pretty much be burning that specific individual.
(Do distro package managers use Certificate Transparency? That would be the hope on the TLS-based side)
With an NSA able to generate a root cert as you say, I’d trust an apt package from a known provider way before the curl|bash stuff or YetAnotherPackageManagerBecause13ArentEnough that people prefer today.
I believe the point was that they wouldn't have to do the paperwork, and wait to run it up the chain for the big guns.
Also, maybe the big guns would not be authorized for this particular op. I think what they were getting at was that there was probably no need for all that as there was no end point protection agent.
And, now I am inferring, that on desktop Linux, with all of the additionally installed attack surface combined with how often people actually run apt update && apt uprgade && apt dist-upgrade... "it was going to be (relatively) easy."
Also, X11 has really poor separation between processes. Any desktop application running in Xorg can keylog all user inputs.
It is possible to build a secure Linux installation but it requires a lot of careful OS knowledge and the discipline to only use a small set of software with established provenance. And probably disabling Javascript.
In macOS/Windows, there are runtime permissions these days which allow you to control which folders can be given to which application.
Linux needs to mainstream a solution like this. One of the most popular way Linux users can handle this today is by associating a user with a application and granting various permissions to that user. However this is a far cry from safe by default, and it requires deep system knowledge.
- autorun and keyboard shortcuts of your window manager -- one can hook an evil command to Ctrl+C
- ~/.mozilla -- you can add arbitrary javascript to your profile or extensions
- any application which does not expect to have its config externally tampered with and this may result in various errors including RCE
- ~/work/FooProject/Makefile, configuration of your IDE (which contains list of commands that shall be executed to compile)
etc.
An explicit allowlist would be a better option, IMHO perfectly manageable - with a popup window "the app wants to access <file>, allow once | allow permanently | deny".
There is no reason why Evince/Okular or mpv (to name a few apps which handle files with complex formats from untrusted sources) should have the right to access anything beside their ~/.config/<application_name> and the file they are currently viewing/playing, or maybe read-only ~/Music. If you want to do a "Save as", you will do this through a OS-controlled file dialog, or save it to /tmp and copy it.
This can be achieved with AppArmor, with a caveat that in X, applications can steal each other's windows, but unfortunately this is not the default and easy configuration on most distros.
I know about this feature on macOS, but how do you configure this on windows?
I’ve seen the protected folders feature or something like that. But that’s not “which app can access which folder”. Rather, “only this list of apps can access this list of folders”.
> Maybe the "this will be easy" part was that without AV software, there was a greater chance that they could just spin up Metasploit, and wouldn't even have to use one their stockpiled zero-days?
Put differently: the gauntlet you have to run on Windows (and to a lesser extent macOS I imagine) is much longer
Anyway, half of those acronyms have more vulnerabilities than Windows on a normal computer.
I don't trust that an AV vendor can _add_ security to a system with a _new_ and obscure binary looking over the kernels shoulder. I don't think the properties of the universe allow for this to ever be true.
I do see how other OSes address this problem differently, such as everything going through a package manager.
But, see my question here regarding how often some is going to run apt update && apt upgrade && apt dist-upgrade, vs. the more automated update systems on MacOS and Windows.
- There is no real concept of base system because distros are usually a patchwork of software from diverse sources. This means stuff like proper secure boot is not really feasible on any distro (although AFAIK the systemd/Fedora people are working on it with signed UKIs and immutable OS images).
- Some features that could live in userland for improved security are instead implemented in the kernel, while both Windows and macOS generally keep moving exploitable features like font rendering to userland.
- Distros often disable or disregard security features such as SELinux or mitigations like CFI.
Here [2] is a more detailed article examining the lack of security of Linux desktops in case you're interested.
On Linux, the attack surface may not be non-existent, but by default it is smaller than some other operating systems. Any halfway competent Linux sysadmin can configure iptables or some other firewall to block all network traffic except what is specifically permitted. Even when something is exposed, it usually only allows access to specific user accounts (including system service accounts.) Once access is granted to an account, you are then constrained by discretionary access controls (DAC) (i.e. POSIX users + groups + file permission modes), and, for the paranoid, by mandatory access control (MAC) (eg AppArmor or SELinux) as well.
As others have said, such access could theoretically allow bootstrapping to greater privilege escalation, especially if you only have DAC and no MAC, but in practice it's harder than it sounds.
I have seen plenty of publicly-exposed Linux VMs compromized over the years. They were always compromized via one of two methods: the admin user explicitly enabled password authentication to ssh instead of adhering to keypairs (which we enforce by default); or, they opened up a vulnerable service such as a database to the public internet. It was never via some virus.
You hear people saying dumb stuff like, oh no one uses Linux and that's why there are no viruses. To that, I say our Linux server farms have a vast amount of highly valuable compute power and research data. If it were possible to infect these machines with a virus, any halfway competent nation state, ransomware group or bitcoin mining conglomerate would very much consider it a worthwhile investment to develop such a virus.
I've been using Linux desktop for 15 years. No viruses so far.
But if I just talked about my personal machines, would anyone listen? I've had a lot more opportunity to see what it looks like when a VM is compromized, compared to a desktop, because my desktop has never been compromized.
Additionally, a lot of Linix users run most attack vectors (like browsers or email clients) inside a sandbox using Snap or FlatPak).
None of these things make it impossible to get through to the system, but they are additional barriers that an attacker needs to deal with.
Do people out there really “allow any” ports on their firewalls? Or are those ports for control inside the firewall only?
I'm playing around with IP address level detecting and blocking using incoming ports as indicators. I'm going to set aside some time to think more about restrictions on outgoing ports as a result of this and your comment.
Do some logging of frequently used remote ports over a couple of weeks and create a baseline set of allowed ports, block everything else and see what breaks.
I already use the limited Feodo Tracker[0] lists to flag in my firewall logs whether any device on the network has attempted to contact a known C&C IP address.
Thanks for push.
Devices reconfigured to NOT do that at all.
Now that's cleared, the log won't be quite so cluttered.
Edited to add: Also redirected a whole load of regular NTP queries to remain internal.
There's sweet FA traffic that should be going out to the 'net when everyone's asleep. But make sure these rules can be switched on and off in case of emergencies.
I had to take my daughter to emergency late one night a few months ago (didn't end up being anything worthy of a story), but got home at 2:30am. My garage door opener gets smart-home-switched-off at 1:00am-ish. At 2:30am, just wanting to go to bed after the stress of an emergnecy room, waiting for that thing to boot up felt like 15 minutes.
But also "Only allow HTTPS out to FAANG" - ok, so now you're allowing encrypted connections to 2 largest cloud providers. At that point what's the benefit at all?
This is a serious allegation to make. Do you happen to have some supporting evidence?
I do understand they don’t want to set any bad precedents internally, but their abuse reporting is abysmal.
It's kinda hard to point to someone saying how big the problem is, because most posts are just "sigh, here's yet another example, anyway...". I wouldn't go as far as saying they're doing this as an intended strategy, but it's definitely a case of it being hard for CloudFlare to care about an issue when they're in business of selling protection from that issue.
As a side note, I’m actually amused that I got downvoted for simply asking for evidence. I think it’s a pretty reasonable to ask folks to substantiate serious allegations made against a company like Cloudflare (a company, I might add, I’m not even a fan of for my own personal/philosophical reasons). I find this behavior very cult-like, but anyway, I digress…
CF are terribly slow to respond to abuse, their ranges are allowlisted everywhere, and it’s not terribly hard to hide your backend infrastructure (origin) even from cloudflare itself.
Sure you have to deal with the eventual takedown of your domain, by CF or more likely the domain registrar, but it’s trivial to work around that (backup domains, frequently rotating them, etc).
What’s funny is how Namecheap are now absolutely god tier at doing takedowns on malicious domains - they used to have a very poor reputation and now will process a takedown (provided evidence) within the hour usually.
A good solution is to block all outgoing traffic on production servers.
It seems so. This traffic likely will not even traverse a firewall -- the article lists the IP addresses used with port 52699, which are all RFC1918 space (172.16.0.0/12).
EDIT: from the article:
The researchers have so far been unable
to determine precisely how Krasue gets
installed. Possible infection vectors
include through vulnerability
exploitation, credential-stealing or
-guessing attacks, or by unwittingly
being installed as trojan stashed in an
installation file or update
masquerading as legitimate softwareBehind that are attacks on Linux web servers where exploits in the web application (e.g. WordPress) or the web framework (e.g. Rails) are the attack vector.
Now that it's at least 2 years after the initial intrusion, it could be pretty tough to determine how that happened and what path the attacker took.
The email attachment may come from your friend/business partner which themselves got infected and the malware is now attaching itself to their legit emails. (AFAIK not very common)
The architecture is pretty good, and I’m surprised it has not been already adopted by OS vendors. But on the other hand, there is huge amount of code installed, and with far fewer eyes on it.
Another option is ChromeOS, but that’s tied to google. Also, I’m not sure if it can replace Linux desktop (there is option of installing Linux).
A third option is a minimax Debian. The software that the user needs will mostly be installed in VMs.
Binary replacement (replacing top, ps, netstat, etc with patched versions) is the oldest trick.
Syscall hooking kernel root kits largely only vary in how exactly they hook the syscalls - there’s a few methods, but the underlying principle is the same.
And then you have userland hooks which usually use LD_PRELOAD to intercept system calls/libc calls to get the job done.
Honestly most of the time a full blown root kit is overkill, just name your binary something innocuous and have it not do anything too fucking obvious and nobody will notice.
https://www.man7.org/linux/man-pages/man2/prctl.2.html
> PR_SET_NAME
> Set the name of the calling thread
I don't understand how this survives major kernel upgrades. I have problems keeping out-of-tree modules working, intentionally. Do rootkits ship with fancy DKMS these days? Do the authors test with upcoming versions of major distros and push an upgrade to support the new release?
At one of my old jobs we had a kernel rootkit we used on occasional red team exercises that ended up having forks for 2.6, a couple of forks for 3.x, and a couple more forks for 4.x - maintenance of that was an absolute nightmare and frankly, not worth the effort in the long run, so it was not maintained into 5.x and replaced with a few much simpler userland backdoors.
That’s why you will see malware such as the one in the article shipping with stuff cobbled together from several different rootkit projects to try obtain some semblance of compatibility.
This awakens memories of GCHQ attacks on Belgian(?) telecom providers; they really are inherent gold mines for dragnet surveillance, stealing database, offensive cyberattacks and probably lots more. There’s a reason Huawei is subsidized for offering cheap 5g infrastructure to international clients, it’s a real nice thing to have backdoors to. Not saying the west is much better in this regard, Cisco has been more than compliant in similar shenanigans just to name one.