security: harden webui (loopback bind, path containment, CORS + error hygiene) - #392
Open
azoz778 wants to merge 1 commit into
Open
security: harden webui (loopback bind, path containment, CORS + error hygiene)#392azoz778 wants to merge 1 commit into
azoz778 wants to merge 1 commit into
Conversation
…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
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.
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 to127.0.0.1withdebug=Falseand the reloader off by default; binding to0.0.0.0is now explicit opt-in via an env var. Previously the dev server was reachable on all interfaces with debug on.load_data_filenow resolves the requested path withrealpathand confines it under thedata/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.str(e)(which could leak paths/internals); generic messages are returned instead, with detail logged server-side.lookback/pred_len/sample_countare bounded to sane ranges.flask-corsbumped 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.