Skip to content

security: harden webui (loopback bind, path containment, CORS + error hygiene) - #392

Open
azoz778 wants to merge 1 commit into
shiyu-coder:masterfrom
azoz778:security/webui-hardening
Open

security: harden webui (loopback bind, path containment, CORS + error hygiene)#392
azoz778 wants to merge 1 commit into
shiyu-coder:masterfrom
azoz778:security/webui-hardening

Conversation

@azoz778

@azoz778 azoz778 commented Aug 17, 2026

Copy link
Copy Markdown

Defensive hardening for the optional webui/, from a security review. No changes to the model or training code — only the web UI surface.

  • webui/app.py / webui/run.py — bind to 127.0.0.1 with debug=False and the reloader off by default; binding to 0.0.0.0 is now explicit opt-in via an env var. Previously the dev server was reachable on all interfaces with debug on.
  • Path containmentload_data_file now resolves the requested path with realpath and confines it under the data/ directory, so a caller can't walk out of it (../) or hand it a URL to make the server fetch arbitrary local files / remote resources.
  • Error hygiene — client-facing responses no longer echo raw str(e) (which could leak paths/internals); generic messages are returned instead, with detail logged server-side.
  • Input clampslookback / pred_len / sample_count are bounded to sane ranges.
  • CORS — restricted to localhost origins; flask-cors bumped to >=4.0.1.

These are opt-in-safe defaults (local dev keeps working; exposing the UI on a network is a deliberate env flag). Glad to adjust naming or defaults to match your intent.

🤖 This came out of an automated security review (Claude Code). Reviewed by the author before submitting.

…leak hardening

Upstream webui/ hardened (edits marked [SECURITY]); serve_webui.py stays the
blessed launcher.
- app.py/run.py: app.run debug=False, host 127.0.0.1 by default (0.0.0.0 only
  via KRONOS_WEBUI_BIND_ALL=1), use_reloader=False — no Werkzeug debugger/LAN.
- load_data_file: realpath-confine file_path to the repo data/ dir (blocks
  arbitrary file read and the pd.read_csv(URL) SSRF).
- stop reflecting str(e) to clients on the load path; log server-side.
- clamp lookback/pred_len/sample_count to sane bounds.
- CORS restricted to the local UI origins; flask-cors>=4.0.1.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J2pmHPESfajho7VL8WyGDF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant