Skip to content

fix(security)!: harden artifact serialization and loading - #2339

Open
XianBW (XianBW) wants to merge 28 commits into
mainfrom
security/harden-artifact-loading
Open

XianBW (XianBW) wants to merge 28 commits into
mainfrom
security/harden-artifact-loading

Conversation

@XianBW

@XianBW XianBW (XianBW) commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Replace HIST's pickled stock-index mapping with validated JSON and fix CPU execution.
  • Use an explicit pickle allowlist for supported NumPy/pandas data, including record arrays and business-calendar frequencies, instead of trusting entire namespaces.
  • Make recorder artifact loading restricted by default, with consistent trusted opt-ins for workflows and record templates, plus per-artifact collector consent. Automatic prediction/label reads remain restricted.
  • Constrain HighFreqProvider's configured and generated artifact paths to artifact_root.
  • Correct DDG-DA cache replay, rolling tails, IC indexing, path handling and shared-template mutation; support disabled LightGBM early stopping and remove an unused PIT calendar dependency.
  • Add security regressions and complete HIST/DDG-DA workflow coverage, plus explicit CI dataset downloads with bounded retries.

Upgrade notes

Breaking change: Reloading saved models, datasets and tasks containing executable objects requires explicit trusted=True (--trusted=True in example CLIs), after verifying their source and storage. Previously saved workflow components without consent default to restricted loading.

HIST's stock_index must use JSON, and high-frequency artifact paths must remain within the configured root. The migration guide explains component-level authorization and data-format compatibility, with examples for restored managers, Arrow columns and timezones.

@XianBW XianBW (XianBW) changed the title security: harden artifact serialization and loading fix(security): harden artifact serialization and loading Sep 2, 2026
@XianBW

Copy link
Copy Markdown
Collaborator Author

Local verification update:

  • 23 security regression tests passed
  • handler serialization plus full train/backtest pipeline: 4 passed
  • repository-wide Black, Flake8, and Pylint passed
  • HIST JSON mapping verified identical to all 735 entries in the previous object NPY
  • added explicit trusted=True to the pipeline test that intentionally restores an arbitrary model pickle

The branch also contains minimal CI compatibility fixes for current Node/commitlint, Plotly, MLflow, and Windows/Python 3.8 OSQP behavior.

@XianBW

Copy link
Copy Markdown
Collaborator Author

Final verification: all 76 GitHub checks pass on commit 9d8d63df/latest branch state, including title, CLA, pip compatibility, source builds, notebook execution, full pytest, and slow pytest matrices.

XianBW (XianBW) and others added 6 commits September 16, 2026 08:22
Allow the exact MaskedArray and SparseDtype module paths emitted by the older dependency versions in CI. Preserve restricted loading and cover both old and new paths.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
PIT normalization uses report dates and calendar-day offsets, so do not request an unused Baostock calendar. Cover annual and quarterly normalization without online calendar access.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Expose default-off artifact trust at online, delayed-training and meta-workflow entry points. Keep data loading restricted, preserve legacy default recorder calls and restored workflow defaults, and document migration and trust boundaries.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Exercise real training, cache and recorder restoration, saved-task replay, signals and portfolio backtests. Fix the cache trust, grouping, relative-path, LightGBM early-stopping and HIST CPU blockers exposed by full execution.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use trusted consistently across public APIs and CLI options. Migrate pre-release saved consent only at serialization boundaries, reject invalid or conflicting settings, and preserve restricted data reads. Add a canonical upgrade guide with README, installation, changelog and runtime-error entry points.

BREAKING CHANGE: executable artifact restoration requires explicit trusted=True. HIST mappings use JSON and high-frequency cache paths must remain within artifact_root. See docs/start/artifact_migration.rst for upgrading existing workflows.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@XianBW XianBW (XianBW) changed the title fix(security): harden artifact serialization and loading fix(security)!: harden artifact serialization and loading Sep 21, 2026
XianBW (XianBW) and others added 4 commits September 21, 2026 15:07
Target upgrades from pre-PR Qlib rather than artifacts generated by intermediate PR revisions. Retain restricted defaults for saved objects without consent, unify current APIs, and remove state/keyword migration branches and documentation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Download the same existing v2 archives used by successful jobs without probing nonexistent package-version assets. Allow five download attempts 60 seconds apart; preserve the full matrix, datasets, noninteractive setup and failure propagation. Cover the exact archives and retry policy in offline CI tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Show explicit consent for restored online components while preserving the original manager, schema-aware Arrow conversions, timezone-preserving ZoneInfo migration, and restricted round trips into a separate recorder. Explain shared-component scope, staging artifacts and trusted-source prerequisites.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep immutable cache references intact at open rolling tails. Add explicit per-load record-template consent and per-artifact collector loading options without widening other reads. Restore the original template class after parent-load failures, and support audited business-frequency and NumPy record representations through exact pickle globals.

Document the scoped APIs and cover fresh trained-model reads, cache generation, numerical round trips and refusal paths.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant