#40485·cowrie

`rethinkdblog` 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/rethinkdblog.py's Output.write() calls r.table(self.table).insert(event).run(self.connection) directly against a rethinkdb connection. The RethinkDB Python driver's default run() is synchronous and performs blocking network I/O. Since write() runs directly on the Twisted reactor thread, every logged event blocks the entire process, freezing every connected honeypot session for the duration of each RethinkDB round trip. Same root cause as the identically-shaped bug already reported against redis.py.

To Reproduce Steps to reproduce the behavior:

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

Expected behavior A slow or unreachable RethinkDB server should not freeze unrelated honeypot sessions; the blocking insert().run() call 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.
  • write() reuses a single mutable RethinkDB connection object across every call; concurrent queries against the same connection from multiple threads are not guaranteed safe by the driver. 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.
  • This file also has a second, unrelated bug (incorrect UTC/local time handling in iso8601_to_timestamp()); I'll report it separately.
  • Patched file: src/cowrie/output/rethinkdblog.py (Output.start(): creates and starts the dedicated thread pool; Output.write(): now defers the (renamed) _insert() body to that pool via twisted.internet.threads.deferToThreadPool instead of running it directly; Output.stop(): stops the thread pool too).

rethinkdblog.py