{{ message }}
Repository navigation
fix: prevent path traversal and disable debug mode in web API - #376
Open
adwaitm1301 wants to merge 1 commit into
Open
adwaitm1301 wants to merge 1 commit into
adwaitm1301 wants to merge 1 commit into
Conversation
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.

Kronos (shiyu-coder/Kronos)
Issue 1 (CRITICAL): Path traversal in web API lets attackers read arbitrary files
In
webui/app.pylines 142-178, the/api/load-dataand/api/predictendpoints accept afile_pathparameter directly from user POST data with no validation. Theload_data_file()function opens whatever path the user provides.An attacker can read arbitrary
.csvor.featherfiles from the server by sending paths like../../etc/passwd. Combined with no authentication and Flask debug mode, this is a serious vulnerability.Suggested fix: Restrict file paths to a designated data directory and validate that resolved paths start with the allowed base directory.
Issue 2 (CRITICAL): Flask debug mode enabled allows remote code execution
In
webui/app.py:725andwebui/run.py:71, the Flask app runs withdebug=True. This enables the Werkzeug interactive debugger. Anyone who triggers an exception can access/consoleand execute arbitrary Python code on the server.Suggested fix: Set debug=False in production and use an env variable to toggle it in dev.
Issue 3 (CRITICAL): Insecure pickle deserialization in finetuning pipeline
In
finetune/dataset.py:39andfinetune/qlib_test.py:220,247,pickle.load()is called on data files with no integrity check. Pickle is inherently unsafe - malicious pickle data can execute arbitrary code during deserialization. Issue #216 already flags this.Suggested fix: Use safetensors (already a dependency) instead of pickle, or add HMAC signing/verification before loading.
Issue 4 (HIGH): Web UI has no authentication or CSRF protection
The web UI at
webui/app.pyhas zero authentication. Flask-CORS is enabled with default permissive settings. Anyone who can reach the server can load models, scan the filesystem, and run predictions.Suggested fix: Add authentication (Flask-Login or JWT), restrict CORS origins, add CSRF protection, and rate-limit prediction endpoints.
Issue 5 (HIGH): Prediction results saved as plaintext JSON without access control
In
webui/app.pylines 173-230, financial prediction results including full OHLCV time series are saved towebui/prediction_results/as plaintext JSON files. These contain potentially sensitive market data and prediction signals.Suggested fix: Encrypt saved prediction files, restrict file permissions to 0o600, and add automatic cleanup for old results.
PR: Fix path traversal and add input validation in web API
This PR addresses Issues 1 and 4 above by:
The web API should never trust user-supplied file paths. This fix ensures that even if an attacker reaches the API endpoints, they cannot traverse outside the designated data directory.