Summary The LangBot plugin runtime starts a debug WebSocket server on 0.0.0.0:5401 (/plugin/ws)
Description
The LangBot plugin runtime starts a debug WebSocket server on 0.0.0.0:5401 (/plugin/ws). Authentication is guarded by plugin_debug_key, which defaults to an empty string and is never set by the official repository, Docker image, or docker-compose — so the check is skipped entirely. Any remote attacker who can reach the port can register a "debug plugin" with no credentials whatsoever. Once registered, the plugin receives every message event flowing through LangBot (including private chats in plaintext), can inject forged replies, register malicious tools into LLM pipelines, enumerate all bots, send messages as any bot, and block legitimate plugin installations.
Details
The runtime unconditionally starts the debug WebSocket server:
# langbot_plugin/runtime/io/controllers/ws/server.py:37-43
server = await websockets.serve(self.handle_connection, "0.0.0.0", self.port)Registration is only verified when a key is configured:
# langbot_plugin/runtime/io/handlers/plugin.py:78-86 (REGISTER_PLUGIN)
if runtime_settings.plugin_debug_key: # default: "" -> skipped
plugin_debug_key = data.get("plugin_debug_key", "")
if plugin_debug_key != runtime_settings.plugin_debug_key:
return handler.ActionResponse.error("Plugin debug key verification failed")```python
langbot_plugin/runtime/settings.py:12
plugin_debug_key: str = Field(default="") # sourced only from data/.env / env var
A repository-wide search shows `PLUGIN_DEBUG_KEY` is never set anywhere in the LangBot repo or `docker/docker-compose.yaml`, while the compose file publishes the port to the host:docker/docker-compose.yaml
langbot_plugin_runtime: ports:
- 5401:5401
After registration, `langbot_plugin/runtime/plugin/mgr.py:720+` (`emit_event`) broadcasts events to **all** INITIALIZED plugins without filtering debug plugins, so the attacker's plugin receives the full `EventContext` of every IM message (`PersonMessageReceived`,`PersonNormalMessageReceived`, `GroupMessageReceived`, `PromptPreProcessing`, ...) — including message chains in plaintext, launcher (user) IDs and sender IDs.
Through the same unauthenticated connection the attacker can also use the plugin API surface, e.g.:
- `send_message()` — send messages as any configured bot (phishing through a trusted identity);
- `get_bots()` — enumerate all bot UUIDs (which are the only barrier protecting the platform webhooks, enabling further webhook forgery);
- `invoke_llm()` — consume all configured LLM models for free;
- `retrieve_knowledge()` — read knowledge-base contents;
- register a malicious `Tool` whose output feeds the LLM pipeline of every user (platform-wide prompt injection);
- pass `"prod_mode": true` at registration — the plugin is then treated as a production plugin, and `_validate_install_target` will reject any later legitimate installation of the same author/name plugin (persistent denial of service).
Relevant code paths:
- `langbot_plugin/runtime/settings.py:12` — `plugin_debug_key` defaults to `""`.
- `langbot_plugin/runtime/io/controllers/ws/server.py:37-43` — WS server bound to `0.0.0.0`, port 5401.
- `langbot_plugin/runtime/io/handlers/plugin.py:74-86` — `REGISTER_PLUGIN`; key verified only when non-empty; `prod_mode` accepted verbatim.
- `langbot_plugin/runtime/plugin/mgr.py:720-760` — `emit_event` broadcasts to all INITIALIZED plugins without filtering debug plugins.
- `docker/docker-compose.yaml` — publishes `5401:5401` to the host by default.
## PoC
Prerequisites:
- Network access to the LangBot plugin runtime port 5401 (published by default in docker-compose).
- No account, token, or any other credential is required.
Steps:
1. Connect to `ws://<host>:5401/plugin/ws` and send `REGISTER_PLUGIN` with an arbitrary plugin container (the official `langbot_plugin` SDK does this out of the box; a raw WebSocket client works too — no `plugin_debug_key` needs to be presented).
<img width="2318" height="1798" alt="image" src="https://github.com/user-attachments/assets/3d5061e1-dd9b-416b-9122-f48f606dff54" />
<img width="2562" height="36" alt="image" src="https://github.com/user-attachments/assets/17aa2d78-45dd-4123-8e8d-303b890e0e5a" />
2. The plugin is registered and initialized: it appears in the LangBot plugin list as `install_source: "debug"`, `enabled: true`.
<img width="1824" height="546" alt="image" src="https://github.com/user-attachments/assets/1805fa0e-c882-40f7-9d01-c5737dcbbdb3" />
3. Send any message to a bot (e.g. via an `http_bot` adapter or any IM platform). The attacker's plugin immediately receives the corresponding events with the plaintext content.
Minimal evidence captured on a default docker-compose deployment (attacker plugin log):
<img width="2366" height="336" alt="image" src="https://github.com/user-attachments/assets/cf3f6272-8e56-46fc-b385-7207ecdd100c" />
A ready-made debug plugin using the official SDK (`manifest.yaml` + an `EventListener` component that registers handlers for all event types, then `lbp run` with `DEBUG_RUNTIME_WS_URL=ws://<host>:5401/plugin/ws`) reproduces this in under a minute.
## Impact
Unauthenticated, remotely exploitable compromise of the entire LangBot message plane (CWE-306 Missing Authentication for Critical Function):
Suggested fixes: generate a random `plugin_debug_key` by default (or fail closed when it is empty), bind the debug WS server to `127.0.0.1` by default, do not publish port 5401 in the reference docker-compose, and filter debug plugins from `emit_event` unless
explicitly subscribed.
## Credits
T4rnRookie