You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/network-services-pentesting/5671-5672-pentesting-amqp.md
+36Lines changed: 36 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -139,6 +139,40 @@ for method, props, body in ch.consume('loot', inactivity_timeout=5):
139
139
140
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
141
142
+
### Consumer-side command injection (message bus -> RCE)
143
+
144
+
Treat every message broker as a potential **code-delivery primitive** when downstream consumers turn message data into shell commands, SQL, template input, or config updates. The critical anti-pattern is a worker that reads attacker-controlled content from a queue/topic and feeds it into a shell, for example `bash -c "$MESSAGE"`, `sh -c`, `os.system`, `subprocess(..., shell=True)`, `Runtime.exec`, or `Command::new("bash").arg("-c").arg(message)`.
145
+
146
+
Typical exploitation chain:
147
+
148
+
1. Gain **publish capability** to a queue/topic:
149
+
- Direct broker access with weak/default credentials or no auth
150
+
- Access to an HTTP publish feature such as RabbitMQ Management `POST /api/exchanges/%2F/<exchange>/publish`
151
+
- SSRF into an internal broker or debug endpoint that can speak raw TCP to the broker
152
+
- Compromise of any producer service that already writes to the target queue/topic
153
+
2.**Locate the sink** in source/config:
154
+
- Workers calling shells after deserializing messages
155
+
- "task runners" that accept commands over the queue
156
+
- Consumers that rebuild config files and then execute hooks/reload scripts
157
+
3. Publish a **benign probe** first (`id`, `whoami`, `uname -a`) to confirm execution without destroying the worker
158
+
4. Upgrade to a reverse shell or data theft once the execution path is confirmed
159
+
160
+
Things to look for during source review:
161
+
162
+
- Consumer groups named `update`, `jobs`, `tasks`, `commands`, `hooks`, `admin`, `dns`, or `sync`
163
+
- Supervisor/systemd entries launching both a broker consumer and a privileged helper in the same container
164
+
- Log lines showing a worker executes each message and then republishes results to a second queue/topic
165
+
166
+
Example RabbitMQ publish through the management API:
The same pattern appears outside AMQP. In Kafka, once you can reach the broker and craft a valid **Produce** request for the attacker-controlled topic, any consumer that forwards the message body to `bash -c` becomes an RCE sink. If the only reachable primitive is SSRF, check whether it can send **raw TCP bytes** or follow a `gopher://` redirect so you can still speak the broker protocol.
175
+
142
176
## Other RabbitMQ ports
143
177
144
178
In [https://www.rabbitmq.com/networking.html](https://www.rabbitmq.com/networking.html) you can find that **rabbitmq uses several ports**:
@@ -172,5 +206,7 @@ In [https://www.rabbitmq.com/networking.html](https://www.rabbitmq.com/networkin
172
206
-[CVE-2024-51988 – RabbitMQ HTTP API queue deletion bug](https://www.cve.news/cve-2024-51988/)
0 commit comments