ZeroHour
Help Net Securitypublished ()ingested @zeljkazorz

Linux systems targeted with stealthy “Perfctl” cryptomining malware

highMalwareimportance 47CVE-2021-4034

Vulnerabilities mentionedAll →

CVEVulnerabilityCVSSEPSSFlagsAffectedExposurePublished
CVE-2021-4034
Out-of-Bounds Read/Write Local Privilege Escalation in polkit pkexec (PwnKit)

CVE-2021-4034 ('PwnKit') is an out-of-bounds read and write (CWE-125/CWE-787) in polkit's setuid-root pkexec utility, which mishandles the calling parameter count and ends up trying to execute environment variables as commands. A local attacker who runs pkexec with crafted environment variables can induce it to execute arbitrary code, gaining administrative (root) rights on the target machine. Because polkit is installed by default on mainstream Linux distributions — including Red Hat Enterprise Linux and its many variants, with the flaw also tracked against Canonical, SUSE, Oracle, Siemens, and StarWind Software products — essentially every standard Linux installation was exposed. The flaw is being actively exploited in the wild: CISA added it to the Known Exploited Vulnerabilities catalog on 2022-06-27 with known ransomware use, and EPSS assigns a 94.9% probability of exploitation (100th percentile). Public proof-of-concept exploits are widely available, making exploitation trivial for any user with local access to an unpatched host.

Do: Apply the polkit/pkexec updates from each distribution vendor immediately per vendor instructions, as required by the CISA KEV catalog. If patching must be delayed, removing the setuid bit from pkexec (e.g., chmod 0755 /usr/bin/pkexec) is a widely documented interim mitigation, though it may affect functionality that relies on pkexec. Prioritize hosts where untrusted or low-privilege users can log in, and hunt for prior exploitation given known ransomware use.

7.895% KEV ransomware PoC ×4
  • polkit project polkit (pkexec utility)
  • Red Hat Enterprise Linux Server
  • Red Hat Enterprise Linux Desktop
  • +9 more
masstens of millions of Linux servers and workstations (polkit/pkexec ships by default on virtually all mainstream distributions)
Full article600 words · extracted from helpnetsecurity.com · click to collapse

Thousands of Linux systems are likely infected with the highly elusive and persistent “perfctl” (or “perfcc“) cryptomining malware and many others still could be at risk of getting compromised, Aqua Security researchers revealed last week.

“In all the attacks observed, the malware was used to run a cryptominer, and in some cases, we also detected the execution of proxy-jacking software,” they shared.

“Perfctl” malware

Though the actual cryptomining is performed by XMRIG Monero cryptomining software, the name of the malware – perfctl – was derived from the name of the cryptominer process established on affected systems. (This process was repeatedly referenced by affected users, who have been looking for remediation advice on online forums for years.)

“By combining ‘perf’ (a Linux performance monitoring tool) with ‘ctl’ (commonly used to indicate control in command-line tools), the malware authors crafted a name that appears legitimate. This makes it easier for users or administrators to overlook during initial investigations, as it blends in with typical system processes,” the researchers explained.

The threat actor is installing the malware either by exploiting known vulnerabilities (e.g., RocketMQ) or 20,000 types of misconfigurations (e.g., lack of authentication in the default configuration of Selenium Grid).

The initial downloaded payload – the installation binary that’s effectively a multipurpose malware-dropper – copies itself from memory to a new location in the /tmp directory and runs the new binary from there. The original process and binary are terminated/deleted, and the new one functions as a dropper and a local command-and-control (C2) process.

The “perfctl” attack flow (Source: Aqua Security)

The malware:

  • Contains and uses an exploit to CVE-2021-4034 (aka PwnKit) to attempt to gain full root privileges
  • Modifies existing scripts to ensure execution of the malware and suppression of mesg errors (that might point to malicious execution), and drops a binary that verifies the execution of main payload
  • Copies itself from memory to half a dozen other locations (with file names that mimic the names of conventional system files)
  • Drops a rootkit to hide its presence and assure persistence, alter network traffic, etc.
  • Drops several trojanized Linux utilities to hide specific attack elements (e.g., cron jobs created during the attack, cryptominer’s CPU consumption, malicious libraries and dependencies used by the malware), to prevent developers or security engineers from poinpointing what is attacking the machine
  • Uses a Unix socket over TOR for external communications
  • Drops and executes the XMRIG cryptominer and, occasionally, proxy-jacking software (roping the machine into a proxy network)

Another interesting thing about this malware is that it lays low – i.e., it stops all cryptomining activity – when a new user logs into the server – as noted by affected users.

Detection, removal, and mitigations

When it comes to cryptojacking, the longer the attackers manage to keep the compromise hidden from the user, the more money they will ultimately “earn”.

This is why the attackers went to great lengths to achieve stealth and persistence.

And while some users might not be too bothered by their system(s) being used for cryptomining or proxying for a while, they should reconsider their stance as the danger might be bigger that they thought.

“[We] have also observed the malware serving as a backdoor to install other families of malware,” the researchers noted.

Spotting “perfctl” malware on your system can be achieved through inspection of directories, processes, system logs and network traffic. Aqua has shared indicators of compromise and risk mitigation advice for users and admins of Linux systems.

Subscribe to our breaking news e-mail alert to never miss out on the latest breaches, vulnerabilities and cybersecurity threats. Subscribe here!

Text extracted automatically; images, tables and formatting may be missing. Original: https://www.helpnetsecurity.com/2024/10/07/perfctl-perfcc-cryptomining-linux/