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
Open
fix(webui): do not expose the Flask debug console on 0.0.0.0 by default#383hexonal wants to merge 1 commit into
hexonal wants to merge 1 commit into
Conversation
`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`) 供确实需要对外暴露时显式开启——把「暴露」变成一个要主动做的动作,而不是默认值。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Both webui entrypoints hard-code
app.run(debug=True, host="0.0.0.0", port=7070).Why this matters
debug=Trueenables the Werkzeug debugger. When an unhandled exception occurs, that debugger serves an interactive console that executes arbitrary Python in the server process — andhost="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.pyandwebui/run.pyeach callapp.runthemselves. Patching onlyapp.pywould 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:
Anyone who was intentionally serving to a LAN sets
KRONOS_WEBUI_HOST=0.0.0.0and 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.