fix(security): constrain config-driven code execution - #2340
Open
XianBW (XianBW) wants to merge 12 commits into
Open
fix(security): constrain config-driven code execution#2340XianBW (XianBW) wants to merge 12 commits into
XianBW (XianBW) wants to merge 12 commits into
Conversation
Collaborator
Author
|
Local verification update:
The branch also contains minimal CI compatibility fixes for current Node/commitlint, Plotly, MLflow, and Windows/Python 3.8 OSQP behavior. |
Collaborator
Author
|
Final verification: all 76 GitHub checks pass on commit |
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.
Summary
eval()with a restricted AST interpretereval()calls with explicit registriesSecurity impact
Qlib expressions now accept only registered operators, constants, and supported expression operations. Python attributes, lambdas, comprehensions, imports, starred arguments, private operators, and arbitrary calls are rejected.
Configuration-driven
.pymodules remain available as an intentional extension mechanism, but only when their resolved path is contained by a caller-provided or Qlib-configuredtrusted_module_rootsdirectory. Symlink and parent-directory escapes are rejected after path resolution.Compatibility
Package module paths such as
qlib.contrib.model.pytorch_traare unchanged. Configurations intentionally loading local Python files must declare trusted roots, for example:The affected LightGBM multi-frequency and TRA examples have been updated accordingly.
Validation
py_compilefor changed Python filesgit diff --checkRef,Mean,If, comparisons, and boolean compositionFull project pytest is delegated to CI because the local base environment does not contain Qlib's complete optional dependency set.