Goal Reached Thanks to every supporter — we hit 100%!

Goal: 1000 CNY · Raised: 1000 CNY

100.0%

CVE-2021-37678 PoC — Arbitrary code execution due to YAML deserialization

Source
Associated Vulnerability
Title:Arbitrary code execution due to YAML deserialization (CVE-2021-37678)
Description:TensorFlow is an end-to-end open source platform for machine learning. In affected versions TensorFlow and Keras can be tricked to perform arbitrary code execution when deserializing a Keras model from YAML format. The [implementation](https://github.com/tensorflow/tensorflow/blob/460e000de3a83278fb00b61a16d161b1964f15f4/tensorflow/python/keras/saving/model_config.py#L66-L104) uses `yaml.unsafe_load` which can perform arbitrary code execution on the input. Given that YAML format support requires a significant amount of work, we have removed it for now. We have patched the issue in GitHub commit 23d6383eb6c14084a8fc3bdf164043b974818012. The fix will be included in TensorFlow 2.6.0. We will also cherrypick this commit on TensorFlow 2.5.1, TensorFlow 2.4.3, and TensorFlow 2.3.4, as these are also affected and still in supported range.
Description
TP Seguridad Informática UTN FRBA 2021
Readme
# [CVE-2021-37678](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-37678) Exploit

Para explotar la vulnerabilidad, es necesario levantar un contenedor docker con un ambiente preparado para levantar Tensorflow con una [versión 2.2.3](https://hub.docker.com/r/tensorflow/tensorflow/tags?page=1&ordering=last_updated&name=2.2.3) la cual todavía tiene la vulnerabilidad.
Consta de:
- Una arquitectura AMD de 64 bits,
- CPU o GPU que puede ejecutar instrucciones AVX
- Python de 64 bits en la versión 3.6.9
- Pip3 en la versión 20.2.4
- Tensorflow en la versión 2.2.3
- PyYAML en la versión 3.12


Verificar si la máquina cuenta con docker ejecutando:
```shell
docker -v
```

Una vez que nuestro sistema operativo tenga docker instalado, correr los siguientes comando en la carpeta raiz de este repositorio para construir y levantar la aplicación:

```shell
docker-compose build
```

```shell
docker-compose up
```

O bien, para levantar sin docker compose:

```shell
docker build -t docker-exploit-tensorflow-vulnerability:1.0 . # para construir la imagen
```
```shell
docker run --add-host=host.docker.internal:host-gateway --name exploit-tensorflow-vulnerability docker-exploit-tensorflow-vulnerability:1.0 # para crear y lanzar el proceso por primera vez
docker start -a exploit-tensorflow-vulnerability # para lanzar el proceso nuevamente
```

Para que el reverse shell funcione, hay que tener [netcat](https://en.wikipedia.org/wiki/Netcat) instalado en la máquina atacante, y levantar un puerto de escucha para una sesión ssh. Ej:
```shell
nc -lvp 10000
```
Luego, se explotará la vulnerabilidad mediante un modelo de IA malicioso, donde lanzaremos la conexión con el atacante.
Hay que configurarle la ip y puerto de escucha del atacante en el archivo [reverseShell.yaml](/src/reverseShell.yaml) 
File Snapshot

[4.0K] /data/pocs/8e1e289546c4be52dd5e9f2ad702d73eb134d00c ├── [ 274] docker-compose.yml ├── [ 277] Dockerfile ├── [1.8K] README.md └── [4.0K] src ├── [1.5K] CreateExampleModel.py ├── [ 833] ExecutePythonScripts.sh ├── [ 263] ExploitTensorflowDeserialization.py ├── [3.9K] model_config.py ├── [ 144] printPasswdFile.yaml └── [ 327] reverseShell.yaml 1 directory, 9 files
Shenlong Bot has cached this for you
Remarks
    1. It is advised to access via the original source first.
    2. Local POC snapshots are reserved for subscribers — if the original source is unavailable, the local mirror is part of the paid plan.
    3. Mirroring, verifying, and maintaining this POC archive takes ongoing effort, so local snapshots are a paid feature. Your subscription keeps the archive online — thank you for the support. View subscription plans →