Skip to content

Harden shared cache downloads and pin the Miniconda installer - #2737

Open
Oke Iyanuoluwa Enoch (Iyanuoluwa007) wants to merge 3 commits into
microsoft:mainfrom
Iyanuoluwa007:shared-cache-integrity-hardening
Open

Oke Iyanuoluwa Enoch (Iyanuoluwa007) wants to merge 3 commits into
microsoft:mainfrom
Iyanuoluwa007:shared-cache-integrity-hardening

Conversation

@Iyanuoluwa007

@Iyanuoluwa007 Oke Iyanuoluwa Enoch (Iyanuoluwa007) commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Describe your changes

Hardening for the shared cache and the Qualcomm python env setup, following the suggestions in #2674.

Shared cache

  • SharedCache._download_blob_list now resolves each local destination and raises ValueError if a blob name would land outside the intended output directory (names with .. segments, absolute or drive paths). Before, blob.name[len(prefix) + 1:] was joined onto the output path without any check.
  • OliveCache.get_output_model_id now keeps 16 hex characters of the run config hash instead of 8, which makes ids much harder to collide with on a shared container. Existing local caches simply miss and rerun the pass.

Miniconda installer

  • create_python_env.sh and create_python_env.ps1 download a pinned release (Miniconda3-py312_26.7.1-1) and verify its SHA-256 (from https://repo.anaconda.com/miniconda/) before executing it, instead of running the moving Miniconda3-latest installer unchecked. The .sh script also switches from the legacy repo.continuum.io host to repo.anaconda.com. Users can still pass their own installer with CONDA_INSTALLER.

Not included: binding cached model.json configs to the run that produced them. That needs a design decision on what to store next to the blob, so I left it for a follow-up.

Checklist before requesting a review

  • Add unit tests for this change.
  • Make sure all tests can pass. (pytest test/test_cache.py test/engine: all pass except test_plot_pareto_frontier, which also fails on main in my env because plotly is not installed)
  • Update documents if necessary.
  • Lint and apply fixes to your code by running lintrunner -a (ruff 0.15.11 check and format on changed Python files; bash -n and the PowerShell parser on the scripts)
  • Is this a user-facing change? If yes, give a description of this change to be included in the release notes.
    Shared cache downloads reject blob names that escape the output directory, cache model ids are 16 characters long, and the Qualcomm env setup verifies a pinned Miniconda installer.

(Optional) Issue link

Addresses #2674

- Reject shared cache blobs whose names resolve outside of the local output
  directory (for example names containing ".." segments or absolute paths)
  instead of writing them wherever the path points.
- Widen the output model id derived from the run config hash from 8 to 16
  hex characters so cache entries are much harder to collide with.
- Download a pinned Miniconda release in the Qualcomm python env setup
  scripts and verify its published SHA-256 before running it, instead of
  executing the moving "latest" installer unchecked.

Addresses microsoft#2674
Copilot AI balanced review requested due to automatic review settings October 16, 2026 19:03
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The containment check rejects absolute-path ONNX entries produced by the existing shared-cache uploader.

1 open finding
What changed in this PR

Hardens Olive’s shared cache and Qualcomm environment setup, addressing part of #2674.

Changes:

  • Rejects blob destinations outside the download directory.
  • Expands output model IDs to 16 hexadecimal characters.
  • Pins Miniconda installers and verifies their SHA-256 checksums.
File Description
test/​test_cache.py Tests valid downloads and path traversal rejection.
olive/​platform_sdk/​qualcomm/​create_python_env.sh Pins and verifies the Linux installer.
olive/​platform_sdk/​qualcomm/​create_python_env.ps1 Pins and verifies the Windows installer.
olive/​cache.py Adds download containment checks and widens model IDs.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread olive/cache.py Resolved
@Iyanuoluwa007

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

cache_model kept absolute model paths for non-HF models, so an ONNX model at
/tmp/model.onnx was uploaded as <id>/model/model//tmp/model.onnx and its
cached config pointed at the producer machine path. The new download
containment check rejects those names. Upload any local model file or folder
under its name instead, so blob names and the cached config are relative to
the cached model folder, and add an upload/download round-trip test.
The new _download_blob_list tests call the private helper directly, which
PyLint flags as protected-access (W0212) in the lint CI job.
@jambayk
Jambay Kinley (jambayk) dismissed their stale review October 30, 2026 01:44

The copied PR has lint issues and CI didn't pass

This branch has not been deployed

No deployments
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.

3 participants