-
Notifications
You must be signed in to change notification settings - Fork 91
Open
0 / 10 of 1 issue completedLabels
review/discussionRFC, a code review task, or discussionRFC, a code review task, or discussion
Description
Singularity is a new Open Source rootkit by @MatheuZSecurity (thank you, Matheu!), which has recently added an LKRG bypass. This "issue" is to formulate our stance on the topic, including how it fits our threat model (or does not), and what we're doing about it.
- LKRG bypasses from kernel vulnerability exploits are more relevant for us and for LKRG users than bypasses from rootkits, since in that case the attacker doesn't yet have legitimate-looking root privileges at the initial stage. This is something to recognize and defend against with our current threat model. But in the case of rootkits, there isn't yet:
- Currently, nothing prevents legitimate root from simply unloading LKRG with
rmmodor effectively disabling it viasysctlbefore loading the rootkit. Therefore, an LKM rootkit bypassing LKRG, and us avoiding or breaking such bypass, will only make practical sense if and when we add protection against unloading LKRG and modifying its configuration LKRG Lockdown #439 @kcdev809. And even then, the question will be about protecting the entire system boot chain, including userland; otherwise, the rootkit could be loaded by modifying files used during the next boot-up. That is, Secure Boot, signatures on everything before LKRG is loaded and on LKRG itself (implemented in RLC-H from CIQ), and kernellockdown. In such system configuration, an LKM rootkit that lacks a valid signature could not be loaded without exploiting a vulnerability even in absence of LKRG. So what LKRG could add on top is mitigation of kernel vulnerability exploits - the same thing that's already our focus - and then post-detection of the rootkit's dirty hacks if it does get loaded anyway. - LKRG monitors the integrity and behavior of the kernel, which often detects rootkits - for example, 8 out of 9 in one study. However, we intentionally allow kernel modules loaded by legitimate root user (not with root access just obtained through a kernel vulnerability) and using only official APIs. We even have additional code that intentionally allows kernel function hooking using
ftrace(which Singularity uses). We try not to break useful functionality. Therefore, writing a rootkit that we don't detect can be done simply by making it as correct as possible, without hacks (perhaps giving up on hiding). I think this is why 1 out of 9 wasn't detected in that old study - it was just a keylogger, not a full-fledged rootkit, which was more likely implemented without hacks. - Nevertheless, Singularity (or some of its behavior) was apparently initially detected by LKRG. Hence the additional bypass code, added in a more recent commit after the project's initial announcement. In a sense, it's a success for LKRG that a rootkit written without regard for LKRG was detected, even if this did not really matter yet.
- As far as we can judge from the bypass code, it won't work if the
sysctllkrg.hide=1is enabled. Incidentally, this same setting also broke the bypass in @a13xp0p0v's exploit. We're once again considering making this option, or part of its effect, enabled by default. - We also remembered that
notraceshould be added to more functions in LKRG Add 'notrace' and 'static' attribute to the most of our internal functions #21 or enabled globally via build options Remove trace-related CFLAGS from the build #454 @kerneltoast. This should breakftracefor intercepting LKRG functions by the rootkit, which is what Singularity does. Incidentally, I see that Singularity itself usesnotraceon its functions - I wouldn't be surprised if that's by our example; we just had not deployed ours widely enough. - We're also revisiting whether we really want to support the use of
ftrace, especially without a way to disable such support. Perhaps we only need to remove or disable part of our code, and Singularity will break (as well as other uses offtrace).
For now, we already proceeded to address item 6 above, via PR #454. So we probably already broke Singularity's bypass as of today - need to test.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
review/discussionRFC, a code review task, or discussionRFC, a code review task, or discussion