Perfctl Malware: A Stealthy Threat Targeting Linux Servers Globally

Linux Express
5 min readOct 6, 2024

--

Linux servers have long been viewed as reliable and secure, but recent developments in the cyber landscape have shown they’re not immune to sophisticated malware attacks. One such threat is Perfctl, a malware that has been actively targeting Linux servers since at least 2021. Perfctl exploits misconfigurations and critical vulnerabilities like CVE-2023–33246 in Apache RocketMQ and CVE-2021–4043 in Polkit to infiltrate systems with devastating consequences.

perfctl-malware-on-linux

This malware doesn’t just stop at cryptocurrency mining — it can serve as a loader, proxy, and even install backdoors for further exploitation. In this article, we’ll explore everything you need to know about Perfctl: how it operates, the damage it can cause, and, most importantly, how to defend against it.

What is Perfctl?

At its core, Perfctl is a multi-functional malware designed to exploit misconfigured and vulnerable Linux servers. While it’s most notorious for cryptocurrency mining, Perfctl can also act as a proxy-jacking tool and loader to deploy additional malware payloads. It leverages misconfigurations and vulnerabilities to gain access and maintain persistence in Linux environments, evading detection using rootkits and other sophisticated techniques.

Main Functions of Perfctl

  • Cryptocurrency Mining: Perfctl uses the Monero (XMRIG) mining software to exploit the infected machine’s CPU resources, generating profits for the attackers.
  • Proxy-jacking: Infected systems are also used as proxies to route internet traffic, allowing cybercriminals to anonymize their activities while earning money by selling network bandwidth.
  • Loader for Malware: Perfctl can act as a loader, dropping and executing additional malicious programs, further compromising the server’s security

Exploitation and Attack Vectors

Perfctl’s ability to infiltrate Linux servers is rooted in its exploitation of misconfigurations and critical vulnerabilities. The two key vulnerabilities exploited are:

1. Misconfigurations

Perfctl targets over 20,000 server misconfigurations, ranging from weak passwords to exposed login interfaces, making many systems vulnerable. This wide range of entry points increases the malware’s reach, potentially affecting millions of Linux servers globally.

2. CVE-2023–33246: Apache RocketMQ Vulnerability

This out-of-bounds read flaw in Apache RocketMQ (versions 5.1.0 and older) has a severity score 10/10, making it a critical vulnerability. When exploited, Perfctl uses this vulnerability to remotely execute commands on vulnerable servers, giving attackers control over the system.

3. CVE-2021–4043: Polkit (PwnKit)

Polkit, another critical vulnerability with a high severity rating, is used by Perfctl to escalate privileges. The malware gains root access by exploiting this vulnerability, enabling it to control the entire system and perform more damaging activities like deploying rootkits and trojanized utilities.

Key Features of Perfctl Malware

Perfctl is not just another piece of malware — it is highly elusive and persistent, using various strategies to stay hidden and maintain control over the infected systems.

1. Evasion Techniques

Perfctl uses advanced evasion techniques such as:

  • Rootkits to hide from system tools.
  • Noisy Activity Suppression: The malware stops all resource-intensive activities when a user logs in, avoiding detection during typical system checks.
  • Background Execution: Perfctl runs quietly as a background service after deleting its original binary, making it difficult to trace.

Persistence Mechanisms

Perfctl ensures its longevity on the infected machine by modifying login scripts like ~/.profile. This allows the malware to activate automatically upon user login and remain operational even after rebooting the system.

Self-Replication

To further hide its presence, Perfctl replicates itself across multiple directories, including /tmp, /usr/bin, and /root/.config, using deceptive file names like libpprocps.so and sh.

Rootkits and Trojanized Utilities

Perfctl replaces essential utilities like ldd, top, lsof, and crontab with malicious versions to ensure that the malware’s activities remain undetected by system administrators.

Malicious Activities and Impact

The ultimate goal of Perfctl is to monetize compromised systems, primarily through crypto mining and proxy-jacking, but it can also enable more nefarious activities.

1. Cryptomining

Perfctl is known to deploy the Monero (XMRIG) miner, consuming server resources to mine cryptocurrency. All communication related to the mining operation is encrypted using the TOR network, making it nearly impossible to trace.

2. Proxy-jacking

In some cases, Perfctl turns the infected machine into a proxy server, allowing other malicious actors to route their internet traffic through the compromised system for anonymity. Attackers earn money by selling unused bandwidth through services like Bitping and Repocket.

3. Backdoor Installation

Once installed, Perfctl opens a backdoor on the infected server, allowing threat actors to deploy additional malware families or conduct surveillance on the system.

Detection Techniques

Perfctl’s stealth makes it difficult to detect, but there are several signs system administrators should watch for:

1. Monitor CPU Usage

Unusual spikes in CPU usage, especially during idle times, may indicate cryptomining activities. If the system is slow without any clear cause, Perfctl might be at work.

2. Inspect Critical Directories

Regularly check directories like /tmp, /usr, and /root for suspicious binaries masquerading as legitimate system files. Files with names like sh or libpprocps.so should raise a red flag.

3. Analyze Network Traffic

Monitor network traffic for TOR-based communications or connections to known crypto mining pools. Suspicious outbound connections could signal that the system is used for proxy jacking or cryptomining.

4. Review Logs

Check for unauthorized modifications to essential files like ~/.profile and /etc/ld.so.preload. These changes may be attempts by Perfctl to gain persistence.

Mitigation and Prevention Strategies

Defending against Perfctl requires a combination of patching vulnerabilities, tightening security controls, and using advanced detection tools.

1. Patch Vulnerabilities

Ensure all vulnerabilities, such as CVE-2023–33246 in Apache RocketMQ and CVE-2021–4043 in Polkit, are patched. Keeping systems up to date is the first line of defense.

2. Restrict File Execution

Set the NOEXE option on critical directories like /tmp and /dev/shm to prevent malicious binaries from being executed.

3. Disable Unused Services

Disable any unnecessary services, especially HTTP services, which could expose the system to external threats.

4. Implement Role-Based Access Control (RBAC)

RBAC limits access to critical files and directories, ensuring only authorized users can make changes. It can significantly reduce the risk of compromise.

5. Deploy Advanced Security Tools

Use anti-malware and runtime protection tools to detect rootkits, trojanize utilities, and file-less malware like Perfctl. These tools should also be able to monitor network traffic for TOR-based communications and other suspicious activities.

Conclusion

Perfctl is a highly persistent and dangerous threat to Linux servers. Its ability to exploit various misconfigurations and vulnerabilities makes it a significant risk for any internet-connected Linux server. System administrators can protect their environments from this elusive malware by understanding how Perfctl operates and taking proactive measures to detect and prevent infections. Staying vigilant, patching vulnerabilities and monitoring systems, and employing advanced detection tools will help mitigate the risk of Perfctl and other similar threats.

References

Security Online — Perfctl Malware

Aqua Security — Perfctl Malware Report​

--

--

Linux Express

Welcome to "Linux Express" – your daily source for everything Linux.