#40489·cowrie

`rmq` (RabbitMQ) output plugin blocks the reactor thread on every `write`, freezing all honeypot sessions

Author: vbontchevCreated Aug 4, 2026Updated Sep 15, 2026

Describe the bug src/cowrie/output/rmq.py's Output._connect() and Output.write() use pika.BlockingConnection -- a client pika itself names and documents as synchronous/blocking -- to connect, declare the exchange, and publish every event via channel.basic_publish(...). Since write() runs directly on the Twisted reactor thread, every logged event (including any reconnection attempt) blocks the entire process, freezing every connected honeypot session for the duration of each RabbitMQ operation. Same root cause as the identically-shaped bug already reported against redis.py.

To Reproduce Steps to reproduce the behavior:

  1. Enable the output_rmq plugin pointed at a RabbitMQ broker (or an address that will hang rather than immediately refuse the connection).
  2. Make the broker slow or unresponsive.
  3. Trigger any logged event and observe that every other connected honeypot session stops responding until the RabbitMQ call (connect, exchange declare, or publish) returns or times out.

Expected behavior A slow or unreachable RabbitMQ broker should not freeze unrelated honeypot sessions; the blocking pika calls should run off the reactor thread.

Server (please complete the following information):

  • OS: This bug is OS-independent (Twisted reactor architecture, no OS-specific code involved).
  • Python: Python 3.14.2
  • Twisted: Twisted 26.4.0

Additional context

  • Cowrie Mode: Shell (default), any protocol.
  • pika.BlockingConnection is explicitly documented by pika as not safe to use from multiple threads concurrently, and this plugin's channel/connection objects are shared across every write. The fix uses a dedicated single-worker twisted.python.threadpool.ThreadPool (started in start(), stopped in stop()) instead of the reactor's default multi-worker pool, keeping the connection's use strictly serialized while still off the reactor thread.
  • Patched file: src/cowrie/output/rmq.py (Output.start(): creates and starts the dedicated thread pool; Output.write(): now defers the (renamed) _publish() body -- including the existing reconnect-and-retry logic -- to that pool via twisted.internet.threads.deferToThreadPool instead of running it directly; Output.stop(): stops the thread pool too).

rmq.py