Skip to content

fix(webui): do not expose the Flask debug console on 0.0.0.0 by default - #383

Open
hexonal wants to merge 1 commit into
shiyu-coder:masterfrom
hexonal:fix/webui-bind-loopback
Open

hexonal wants to merge 1 commit into
shiyu-coder:masterfrom
hexonal:fix/webui-bind-loopback

Conversation

@hexonal

@hexonal hexonal commented Aug 4, 2026

Copy link
Copy Markdown

Both webui entrypoints hard-code app.run(debug=True, host="0.0.0.0", port=7070).

Why this matters

debug=True enables the Werkzeug debugger. When an unhandled exception occurs, that debugger serves an interactive console that executes arbitrary Python in the server process — and host="0.0.0.0" publishes it to every machine on the current network. The README lists the webui as a local demo, so in practice this runs on laptops that join cafe, hotel and office wifi.

Werkzeug does require a PIN for the console, and it is printed to the terminal — but the PIN is derived from machine-stable inputs, and the debugger has a long history of PIN-bypass writeups. Either way, an unauthenticated remote endpoint whose failure mode is remote code execution should not be the default for a demo UI.

Note on scope

webui/app.py and webui/run.py each call app.run themselves. Patching only app.py would leave the problem in place for the path the README lists first (python run.py), so this changes both.

Fix

Defaults chosen for a laptop rather than a server — bind loopback, debugger off — with both still reachable for deliberate use:

KRONOS_WEBUI_HOST   default 127.0.0.1
KRONOS_WEBUI_PORT   default 7070
KRONOS_WEBUI_DEBUG  default 0, set to 1 to re-enable the debugger

Anyone who was intentionally serving to a LAN sets KRONOS_WEBUI_HOST=0.0.0.0 and is exactly where they were. Anyone who was not is no longer publishing a remote console without knowing it. The bound address is now printed on startup so the actual behaviour is visible rather than assumed.

`app.py` 与 `run.py` 都写死 `app.run(debug=True, host='0.0.0.0', port=7070)`。
`debug=True` 会启用 Werkzeug 的交互式调试器,那个页面可以**通过浏览器执行任意
Python**;`0.0.0.0` 让它对同一网段的每一台机器可见。笔记本连上咖啡馆或办公室
wifi 的那一刻,这台机器就是敞开的。

两个文件都要改。`run.py` 第 78 行是 `from app import app` 之后自己调 `app.run`,
所以只加固 `app.py` 对它完全无效——而 README 恰恰把 `python run.py` 列为第一条
启动方式,也就是大多数人实际走的那条路。

改成默认 `127.0.0.1` + `debug=False`,并保留三个环境变量
(`KRONOS_WEBUI_HOST` / `KRONOS_WEBUI_PORT` / `KRONOS_WEBUI_DEBUG`)
供确实需要对外暴露时显式开启——把「暴露」变成一个要主动做的动作,而不是默认值。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant