`CowrieServer`'s docstring says it's shared per source IP so SFTP uploads are visible in SSH sessions, but it's actually created fresh for every single connection
No fix is included with this report. This is a mismatch between documented intent and actual behavior, and I don't know which side is "correct" -- whether the sharing was intentionally dropped at some point (e.g. for isolation/security/complexity reasons) and the docstring never updated, or whether it's a genuine regression that should be restored. That's a design call for the maintainer either way.
Describe the bug
src/cowrie/shell/server.py's CowrieServer class docstring:
class CowrieServer:
"""
In traditional Kippo each connection gets its own simulated machine.
This is not always ideal, sometimes two connections come from the same
source IP address. we want to give them the same environment as well.
So files uploaded through SFTP are visible in the SSH session.
This class represents a 'virtual server' that can be shared between
multiple Cowrie connections
"""This describes a specific, useful feature: two connections from the same attacker (e.g. an SFTP session and a separate SSH session, or two SSH sessions) should see the same virtual filesystem, so a file uploaded in one is visible in the other.
But nothing in the codebase actually implements that sharing. Both
places that construct a CowrieServer -- src/cowrie/shell/realm.py's
HoneyPotRealm.requestAvatar() and the analogous
src/cowrie/llm/realm.py -- construct a brand new instance on every
single requestAvatar() call, with no lookup or cache keyed by source IP
(or by anything else):
def requestAvatar(self, avatarId, _mind, *interfaces):
user: IConchUser
if IConchUser in interfaces:
serv = shellserver.CowrieServer(self)
user = shellavatar.CowrieUser(avatarId, serv)
return interfaces[0], user, user.logout
if ITelnetProtocol in interfaces:
serv = shellserver.CowrieServer(self)
user = session.HoneyPotTelnetSession(avatarId, serv)
return interfaces[0], user, user.logout
raise NotImplementedErrorI searched the whole repository for every CowrieServer( construction
site and found only these two, neither of which does any IP-based
lookup or reuse. Each new connection -- even two simultaneous SSH
sessions or an SFTP session and an SSH session from the exact same
source IP -- gets a completely fresh CowrieServer, and therefore a
completely fresh HoneyPotFilesystem (via initFileSystem()), with no
sharing at all. A file uploaded over SFTP in one session is not visible
in a separate concurrent (or even sequential) SSH session from the same
IP, contrary to what the docstring describes.
To Reproduce Steps to reproduce the behavior:
- Open an SFTP session to Cowrie and upload a file.
- Open a separate SSH shell session from the same source IP (same attacker).
- Look for the uploaded file in the shell session's filesystem.
- It won't be there -- each session has its own independent
HoneyPotFilesysteminstance, since each got its own freshCowrieServer.
This can also be confirmed by code inspection alone: grep the whole repo
for CowrieServer( and note that both construction sites are
unconditional, with no cache or lookup structure anywhere connecting
them by source IP.
Expected behavior
Either the documented behavior should be implemented (share one
CowrieServer -- and therefore one HoneyPotFilesystem -- across
concurrent/sequential connections from the same source IP), or, if that
was intentionally dropped, the docstring should say so instead of
describing a feature that doesn't exist.
Server (please complete the following information):
- OS: This bug is OS-independent (a documentation/behavior mismatch in pure Python object lifecycle logic, no OS-specific code involved).
- Python: Python 3.14.2
- Twisted: Twisted 26.4.0
Additional context
- Cowrie Mode: Shell (default); also present in the analogous LLM-backend realm (
src/cowrie/llm/realm.py). - No patched files are included; left to the maintainer's judgement on which side (implementation or docstring) should change.
Source: cowrie/cowrie