`redis` output plugin blocks the reactor thread on every `write`, freezing all honeypot sessions
Describe the bug
src/cowrie/output/redis.py's Output.write() calls the configured
send_method (lpush/rpush/publish) directly against a
redis.StrictRedis client. The redis package (redis-py) performs
synchronous, blocking network I/O for every command, and its default
socket timeout is unbounded. write() is invoked directly on the
Twisted reactor thread (there is no threading or deferral anywhere in
the call chain from cowrie.core.output.Output), so every single
logged event blocks the entire process -- freezing every connected
honeypot session, across every protocol -- for the duration of the
round trip to Redis, and indefinitely if the Redis server becomes
unresponsive. This is the same class of problem this codebase already
guards against elsewhere: backend_pool/pool_service.py's
producer_loop() and the abuseipdb.py and s3.py output plugins all
already use twisted.internet.threads.deferToThread for exactly this
reason; redis.py is the one plugin using a blocking client without
that protection.
To Reproduce Steps to reproduce the behavior:
- Enable the
output_redisplugin pointed at a Redis server (or a host/port that will hang rather than immediately refuse the connection). - Make the Redis server slow or unresponsive (e.g. block its port with a firewall rule so connection attempts hang instead of failing fast).
- Trigger any logged event (e.g. a login attempt) and observe that every other connected honeypot session (SSH, Telnet, any protocol) stops responding until the Redis call returns or times out, since they all share the same single-threaded reactor.
Expected behavior A slow or unreachable Redis server should not freeze unrelated honeypot sessions; the blocking Redis 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 -- this affects the whole process, not just the session that happened to trigger the slow write.
- Patched file:
src/cowrie/output/redis.py(Output.write(): thesend_methodcall now runs viatwisted.internet.threads.deferToThreadinstead of directly on the reactor thread. Individual writes have no ordering dependency on each other, so the default multi-worker pool is sufficient here).
Source: cowrie/cowrie