Re:New ultra-stealthy Linux backdoor isn’t your everyday mal...
by mid-kid on Friday June 10, 2022 @08:51AM
(#31693351)
How do you detect one?
[ Parent
| on HN ]
Re:New ultra-stealthy Linux backdoor isn’t your everyday mal...
by psacawa on Friday June 10, 2022 @09:01AM
(#31693472)
I don't know what the correct thing to do, but you can easily detect processes that have the LD_PRELOAD environment variable defined. This is a rare enough use case for manual inspection. Something like
``` for f in /proc/*/environ ; do sudo strings $f | >/dev/null grep LD_PRELOAD && echo $f; done ```
Re:New ultra-stealthy Linux backdoor isn’t your everyday mal...
by shaded-enmity on Friday June 10, 2022 @09:22AM
(#31693785)
1. Can't the process just scrub LD_PRELOAD from its environment? Linker already done it's job at that point.
2. I'd suggest against using `strings` (let alone with sudo) on attacker controlled inputs
Re:New ultra-stealthy Linux backdoor isn’t your everyday mal...
by shaded-enmity on Friday June 10, 2022 @11:47AM
(#31695780)
Turns out (1) works:
#include <stdio.h>
#include <stdlib.h>
static void begin() __attribute__((constructor));
void begin() {
unsetenv("LD_PRELOAD");
}
Build with: gcc -shared -fpie -o library.so library.c
Test: LD_PRELOAD=~/library.so env | grep LD_PRELOAD
Re:New ultra-stealthy Linux backdoor isn’t your everyday mal...
by rurban on Sunday June 12, 2022 @12:26AM
(#31711428)
Usually guarded with an #ifndef DEBUG. Disallow LD_PRELOAD in Release builds
Re:New ultra-stealthy Linux backdoor isn’t your everyday mal...
by BenjiWiebe on Friday June 10, 2022 @02:16PM
(#31697582)
You could look at the maps of a process instead of the environ. That would show it.
Unless the ld_preload patches the process you are using to read the maps file, and gives you a false maps file.
Re:New ultra-stealthy Linux backdoor isn’t your everyday mal...
by alex_duf on Friday June 10, 2022 @09:46AM
(#31694133)
I'm curious about 2, why?
Re:New ultra-stealthy Linux backdoor isn’t your everyday mal...
by GabrielTFS on Friday June 10, 2022 @09:59AM
(#31694330)
Some versions of `strings` might try to parse the file as an executable, which could expose one to any vulnerabilities that may be present in the library used to do so.
However, on my Fedora 36 machine at least, it doesn't do so by default and I'd have to specify the `-d` flag for it to do this.
Re:New ultra-stealthy Linux backdoor isn’t your everyday mal...
by shaded-enmity on Friday June 10, 2022 @09:55AM
(#31694262)
This is a nice summary: https://lcamtuf.blogspot.com/2014/10/psa-dont-run-strings-on...
Re:New ultra-stealthy Linux backdoor isn’t your everyday mal...
by chrismorgan on Friday June 10, 2022 @09:22AM
(#31693792)
Just tried it, I have it happening naturally in two places:
• libinput-gestures has spawned a /usr/lib/libinput/libinput-debug-events process with LD_PRELOAD=/usr/lib/coreutils/libstdbuf.so
• Firefox has spawned many /opt/firefox-nightly/firefox-bin processes with LD_PRELOAD=libmozsandbox.so
Re:New ultra-stealthy Linux backdoor isn’t your everyday mal...
by mid-kid on Friday June 10, 2022 @09:20AM
(#31693758)
Can't an LD_PRELOAD virus just hijack fopen/fread/etc to modify the contents of the file if its path matches the pattern you described?
Re:New ultra-stealthy Linux backdoor isn’t your everyday mal...
by miohtama on Friday June 10, 2022 @09:53AM
(#31694228)
Yes it can. However I would assume the surface to block all diagnostics paths would be quite large and there is always some command/syscall left unblocked to detect any rootkit. Creating 100% stealth malware is possible, but difficult.
Re:New ultra-stealthy Linux backdoor isn’t your everyday mal...
by Cthulhu_ on Friday June 10, 2022 @09:32AM
(#31693928)
Wouldn't this malware be able to infect each of these steps and the shell itself to filter itself out of the results?
Re:New ultra-stealthy Linux backdoor isn’t your everyday mal...
by prvit on Friday June 10, 2022 @12:16PM
(#31696163)
LD_PRELOAD rootkits are super common, you’re doing it wrong if you’re using dynamically linked binaries to look for malware on Linux.
Re:New ultra-stealthy Linux backdoor isn’t your everyday mal...
by LinuxBender on Friday June 10, 2022 @10:46AM
(#31694955)
I see those defined when I use firejail + firefox.
LD_PRELOAD=libmozsandbox.so
Re:New ultra-stealthy Linux backdoor isn’t your everyday mal...
by josephcsible on Friday June 10, 2022 @09:45AM
(#31694110)
One of the easiest ways would be using a statically linked BusyBox. This works because statically linked binaries are unaffected by LD_PRELOAD, and BusyBox has equivalents of several of the tools that would find it if not for its hiding attempts.