SpiderLabs Blog

Trustwave Threat Hunting Guide: Identifying PwnKit (CVE-2021-4034) Exploitation | Trustwave

Written by Reegun Jayapaul | Jan 26, 2022 6:00:00 AM

The Trustwave Threat Hunting team has authored a practical guide to help the cybersecurity community address the Linux “polkit” Local Privilege Escalation vulnerability (CVE-2021-4034) by identifying common behavior in exploitation.

Overview

On January 25, 2022, Qualys released a research blog detailing a critical vulnerability (aka PwnKit) in the “polkit” component available by default in almost all Linux distributions. At the time of this writing, the Trustwave Threat Hunt team has not witnessed any attacks in the wild using this Local Privilege Escalation.

Our team of threat hunters leveraged the Endpoint Detection and Response (EDR) API across our advanced tier client environment to determine if there was activity from non-root users accessing the ‘gconv-module’ file. This action can also be performed via a normal EDR query or a File Integrity Monitor. If there are findings where non-root users are seen modifying or acting on this file, the following techniques can be used to determine if it is malicious activity indicative of PwnKit exploitation.

How to investigate the results

  1. Check the timeline of events up to two minutes before the file access or modification for any curl/wget execution.
  2. Check the timeline of events up to two minutes before the file access or modification for any shellcode execution, similar to the below:

            ./anyname       
            or
            anyname.py
            or
            anyname.sh

  1. Check the timeline of events up to one minute before the file access or modification for any compilation like this in command line:

            sh -c gcc -o payload.so -shared -fPIC payload.c

  1. Check for username after the event file write/create "gconv-modules". If it is ROOT, then this may be indicative of malicious privilege escalation events.

How the exploit works and how to verify

  1. The exploit will create two folders under the current directory; the folder name can be any random name and "GCONV_PATH="
  2. The two folders will have an exploit attempt file, which can be any random name.
  3. Once the setup is done, the exploitation starts by executing "/usr/bin/pkexec" as ROOT user permission.
  4. You can observe the remaining process will be under ROOT user. This is where the adversary is executing the commands by obtaining ROOT user-level permission.

Summary

Although Local Privilege Escalation vulnerabilities require access to the vulnerable system, do not discount this vulnerability. When paired with any simple Remote Code Execution (RCE) vulnerability, this becomes a part of a critical attack chain. Given the massive attack surface that affects most every Linux distribution, this vulnerability will have legs that make it a threat well into 2022.

For more information about PwnKit (CVE-2021-4034), please refer to our Action Response.

Not every organization has the resources or expertise to perform Threat Hunting. Trustwave offers Threat Hunting services that combine human experts and automated processes to bring you purpose-built threat hunting capabilities that help you stay ahead of advanced adversaries.