Table of Contents
  • Home
  • /
  • Blog
  • /
  • How Does Dirty Cred Vulnerability Work? And How to Protect Your Linux Kernel From Dirty Cred Vulnerability?
August 23, 2022
|
8m

How Does Dirty Cred Vulnerability Work? And How to Protect Your Linux Kernel From Dirty Cred Vulnerability?


How Does Dirty Cred Vulnerability Work And How To Protect Your Linux Kernel From Dirty Cred Vulnerability

A group of academics from Northwestern University has disclosed a new privilege escalation vulnerability dubbed Dirty Cred in the Linux Kernel. Researchers say that though the new exploitation is similar in impact as same as the 6-month-old privilege escalation vulnerability Dirty Pipe, however it is more universal in nature. We are here to let you know more about the Dirty Cred vulnerability, like how does it work and how you should protect your Linux Kernel from the vulnerability. Since it is more generic than any other Kernel permission bypass vulnerability, it is much required to know how does Dirty Cred vulnerability work and how you should protect your Linux Kernel from Dirty Cred vulnerability.

Dirty Pipe vs Dirty Cred

If you remember Dirty Pipe (CVE-2022-0847), one of the serious privilege escalation vulnerabilities that made news headlines early in the year, which abuses the Linux kernel pipe mechanism to inject data to arbitrary files. Dirty Cred also has the capability to create the same impact as Dirty Pipe. Although Dirty Cred has the same impact, it is more generic and powerful than Dirty Pipe vulnerability. This is because, Dirty Pipe, as a vulnerability, doesnt deal with kernel address randomization and pointer integrity check; moreover, a pipe-abusive power is required to exploit the Dirty Pipe vulnerability, which is harder to follow.

Image Source:

Well, in the case of Dirty Cred, it works with any vulnerabilities with double-free ability to demonstrate dirty-pipe-like ability. Additionally, it inherits all the kernel protections bypass capabilities and takes the Dirty Pipe like vulnerability to the next level that allows the ability to overwrite an arbitrary file to escalate privilege. Researchers also noted that Dirty Cred vulnerability is capable of escaping the container actively that dirty pipe is not capable of.

Despite all these, what makes Dirty Cred different then Dirty Pipe is that Dirty Pipe abuses the Linux Kernel mechanism to inject data into unprivileged arbitrary files. The same Dirty Cred also abuses the Linux Kernel credential permission mechanism to write data to unprivileged arbitrary files and run high privileged commands in root contests.

Summary of Dirty Cred Vulnerability – CVE-2022-2588

Dirty Cred is a local privilege escalation vulnerability that is capable of bypassing kernel credential permission checks such as Control Flow Integrity (CFI). The vulnerability has been tracked under the CVE ID CVE-2022-2588, with a CVSS score of 6.7 that enables attackers to perform privilege escalation by bypassing kernel credential permission checks.

The flaw lice in improper implementation of route4_change in the net/sched/cls_route.c filter in the Linux Kernel. The problem is due to the non-removal of an old filter from the hashtable before freeing it in some conditions. The flaw allows a local attacker to perform privilege escalation attacks and achieve further attacks like a denial of service, system crash, arbitrary code execution, and arbitrary command execution.

This image is captured by the author

Important Points to Be Noted About the Dirty Cred Vulnerability:

  1. This is a local privilege escalation vulnerability, so advisories should have a local reach to the victims machine to exploit the flaw.

  2. It is able to bypass kernel credential permission checks like CFI using the flaw.

  3. The problem is due to the non-removal of an old filter from the hashtable before freeing it in some conditions.

  4. It allows attackers to perform a denial of service, system crash, arbitrary code execution, and arbitrary command execution attacks on the victim.

Associated CVE IDCVE-2022-2588
DescriptionA local privilege escalation vulnerability in the Linux Kernel
Associated ZDI ID
CVSS Score6.7 Medium
VectorCVSS:3.1/AV:L/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H
Impact Score
Exploitability Score
Attack Vector (AV)Local
Attack Complexity (AC)Low
Privilege Required (PRHigh
User Interaction (UI)None
ScopeUnchanged
Confidentiality (C)High
Integrity (I)High
Availability (a)High

This image is captured by the author

Kernel Version Affected by the Dirty Cred Vulnerability – Cve-2022-2588

Since the flaw affects all versions of the Linux Kernel, it affects pretty much everything that is built on the Linux Kernel. At the time of publishing this article, no patches were rolled out by Kernel moderators since we are still in the early stage of the bug. We recommend doing a regular check-in kernel.org to see the latest updates on the release of the new Kernel version.

For more information about the affected Kernel versions, please visit your Linux distributions.

How Does Dirty Cred Vulnerability Work?

To understand the Dirty Cred vulnerability, it is required to know about the Kernel Credential and User Permission System in Linux. Theoretically, Linux has 7 types of objects: Tasks, Files/inodes, Sockets, Message queues, Shared memory segments, Semaphores, and Keys. All these objects are associated with a set of credentials to define the ownership and access permission of these objects. The Dirty Cred vulnerability has been described using Task and File credentials.

List of Objects in Linux Kernel: 

  • Tasks

  • Files/inodes

  • Sockets

  • Message queues

  • Shared memory segments

  • Semaphores

  • Keys

The root problem with the Dirty Cred vulnerability is that it allows an attacker to swap their unprivileged credentials with privileged ones, which could be either task or file credentials. You can check out the 

 slides for detailed technical information.

In simple words, Linux Kernel allocates any tasks, no matter whether it is an unprivileged, privileged, legitimate, or illegitimate tasks, to a non-allocated free kernel heap memory for execution. What this bug offers to an attacker is it allows attackers to free up the memory of one of their unprivileged tasks and wait for a privileged task to fill up that memory.

Attackers need not wait for an administrator to perform a task on that attackers freed memory. Attackers can burst the memory utilization by trying to run thousands of their privileged tasks like su, mount, or sshd. Eventually, at some point in time, upon the completion of the cycle there, a time comes that allocate one of his privileged tasks will be allocated to the same memory that he freed up early. As soon as it happens, the attacker will be able to use the privileged task as a root user. 

Step 1. Attacker running multiple unprivileged task on the Kernel Heap memory

Attacker running multiple unprivileged task on the Kernel Heap memory.

Step 2. Attacker uses a vulnerability like Dirty Pipe to freed up a memory of unprivileged task

Attacker uses a vulnerability like Dirty Pipe to freed up a memory of unprivileged task.

Step 3. Attacker freed up a unprivileged task with a vulnerability

Attacker freed up a unprivileged task from the kernel heap with a vulnerability like Dirty Pipe and wait until a privileged refills the memory.

Step 4. A privileged task has refilled in the freed memory

A privileged task has refilled in the freed memory was used by the attacker earlier.

The same applies to open file credentials as well.

  1. Basically, the attacker will write a file to memory with read-write (RDWR) permissions where he has access.

  2. Then the attacker will free the file object once the permission checks are done.

  3. Later the attacker will get a read-only (RDONLY) file to the same space freed in the second step.

  4. The attacker is going to get read-write (RDWR) access as the permission checks are done previously.

Image Source:

Note: Attackers do not need to wait for an administrator to write a file object to that attackers freed memory. The attacker can run scripts to reallocate a read-only file to that space.  

Researchers have published a PoC on GitHub that describes this flaw. Followed by that, 

 has published a video tutorial on his YouTube channel that shows how to test the Dirty Cred vulnerability on publicly hosted servers. If you want, you can play with it.

Source:

How to Protect Your Linux Kernel From Dirty Cred Vulnerability?

Since we are still in the early stage of the research work, it is yet to release the patch. Keep visiting the links we shared in this post to track an update about the fix. 

Generally, security researchers have recommended isolating privileged credentials from unprivileged credentials in vmalloc to avoid cross cash attacks. However, there is no proper fix released to protect your Linux Kernel from Dirty Cred vulnerability at the time of writing this post.

There is a patched code that is made available on GitHub to patch the Dirty Cred flaw. If you want to implement it on your own, you can try it out.

We hope this post would help you know how does Dirty Cred vulnerability work and how should you protect your Linux Kernel from Dirty Cred vulnerability. Please share this post if you find this interested. Visit our social media page on Facebook, LinkedIn, Twitter, Telegram, Tumblr, Medium & Instagram, and subscribe to receive updates like this.

Arun KL

Arun KL is a cybersecurity professional with 15+ years of experience in IT infrastructure, cloud security, vulnerability management, Penetration Testing, security operations, and incident response. He is adept at designing and implementing robust security solutions to safeguard systems and data. Arun holds multiple industry certifications including CCNA, CCNA Security, RHCE, CEH, and AWS Security.

Recently added

Application Security

View All

Learn More About Cyber Security Security & Technology

“Knowledge Arsenal: Empowering Your Security Journey through Continuous Learning”

Cybersecurity All-in-One For Dummies - 1st Edition

"Cybersecurity All-in-One For Dummies" offers a comprehensive guide to securing personal and business digital assets from cyber threats, with actionable insights from industry experts.

Tools

Featured

View All

Learn Something New with Free Email subscription

Subscribe

Subscribe