Skip to content

Enhance path validation in check_tarfile_security for windows#20924

Merged
TomeHirata merged 2 commits intomlflow:masterfrom
TomeHirata:fix/path-traversal-windows
Feb 19, 2026
Merged

Enhance path validation in check_tarfile_security for windows#20924
TomeHirata merged 2 commits intomlflow:masterfrom
TomeHirata:fix/path-traversal-windows

Conversation

@TomeHirata
Copy link
Collaborator

Related Issues/PRs

https://huntr.com/bounties/5d83cc95-1d97-4780-ad16-62756eb0914f

What changes are proposed in this pull request?

See this ticket for details

How is this PR tested?

  • Existing unit/integration tests
  • New unit/integration tests
  • Manual tests

Does this PR require documentation update?

  • No. You can skip the rest of this section.
  • Yes. I've updated:
    • Examples
    • API references
    • Instructions

Does this PR require updating the MLflow Skills repository?

  • No. You can skip the rest of this section.
  • Yes. Please link the corresponding PR or explain how you plan to update it.

Release Notes

Is this a user-facing change?

  • No. You can skip the rest of this section.
  • Yes. Give a description of this change to be included in the release notes for MLflow users.

What component(s), interfaces, languages, and integrations does this PR affect?

Components

  • area/tracking: Tracking Service, tracking client APIs, autologging
  • area/models: MLmodel format, model serialization/deserialization, flavors
  • area/model-registry: Model Registry service, APIs, and the fluent client calls for Model Registry
  • area/scoring: MLflow Model server, model deployment tools, Spark UDFs
  • area/evaluation: MLflow model evaluation features, evaluation metrics, and evaluation workflows
  • area/gateway: MLflow AI Gateway client APIs, server, and third-party integrations
  • area/prompts: MLflow prompt engineering features, prompt templates, and prompt management
  • area/tracing: MLflow Tracing features, tracing APIs, and LLM tracing functionality
  • area/projects: MLproject format, project running backends
  • area/uiux: Front-end, user experience, plotting, JavaScript, JavaScript dev server
  • area/build: Build and test infrastructure for MLflow
  • area/docs: MLflow documentation pages

How should the PR be classified in the release notes? Choose one:

  • rn/none - No description will be included. The PR will be mentioned only by the PR number in the "Small Bugfixes and Documentation Updates" section
  • rn/breaking-change - The PR will be mentioned in the "Breaking Changes" section
  • rn/feature - A new user-facing feature worth mentioning in the release notes
  • rn/bug-fix - A user-facing bug fix worth mentioning in the release notes
  • rn/documentation - A user-facing documentation change worth mentioning in the release notes

Should this PR be included in the next patch release?

Yes should be selected for bug fixes, documentation updates, and other small changes. No should be selected for new features and larger changes. If you're unsure about the release classification of this PR, leave this unchecked to let the maintainers decide.

What is a minor/patch release?
  • Minor release: a release that increments the second part of the version number (e.g., 1.2.0 -> 1.3.0).
    Bug fixes, doc updates and new features usually go into minor releases.
  • Patch release: a release that increments the third part of the version number (e.g., 1.2.0 -> 1.2.1).
    Bug fixes and doc updates usually go into patch releases.
  • Yes (this PR will be cherry-picked and included in the next patch release)
  • No (this PR will be included in the next minor release)

…eventing Windows path traversal vulnerabilities. Added tests for escaped path handling to ensure compliance with security standards.

Signed-off-by: Tomu Hirata <tomu.hirata@gmail.com>
Copilot AI review requested due to automatic review settings February 17, 2026 14:53
@github-actions github-actions bot added v3.10.0 size/S Small PR (10-49 LoC) area/tracking Tracking service, tracking client APIs, autologging rn/bug-fix Mention under Bug Fixes in Changelogs. labels Feb 17, 2026
@TomeHirata TomeHirata changed the title Enhance path validation for windows Enhance path validation in check_tarfile_security for windows Feb 17, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Improves tar archive path validation to prevent Windows-style backslash path traversal from bypassing check_tarfile_security, and adds a regression test to cover the bypass case.

Changes:

  • Normalize tar member names by converting \ to / before posixpath.normpath during validation.
  • Add a unit test that creates a tar entry with ..\\..\\... traversal and asserts it is rejected.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
mlflow/utils/file_utils.py Normalizes backslashes before validating tar member paths to prevent Windows separator bypass.
tests/utils/test_file_utils.py Adds a regression test for backslash-based traversal in tar member names.
Comments suppressed due to low confidence (1)

mlflow/utils/file_utils.py:1037

  • check_tarfile_security now normalizes backslashes, but the absolute-path check only rejects POSIX-style absolute paths (path.startswith('/')). On Windows, tar entries like C:\tmp\pwned.txt (-> C:/tmp/pwned.txt) are still treated as relative and could escape the extraction dir. Consider rejecting Windows absolute paths too (e.g., via pathlib.PureWindowsPath(path).is_absolute() / ntpath.isabs() on the normalized path) and add a unit test for a drive-letter absolute member name.
            # Normalize backslashes to forward slashes before path validation to prevent
            # bypass on Windows where backslashes are treated as directory separators.
            path = posixpath.normpath(m.name.replace("\\", "/"))
            if m.issym():
                symlink_set.add(path)
            else:
                if path.startswith("/"):
                    raise MlflowException(

@TomeHirata TomeHirata added the team-review Trigger a team review request label Feb 18, 2026
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: TomuHirata <tomu.hirata@gmail.com>
@github-actions
Copy link
Contributor

Documentation preview for ba6533a is available at:

More info
  • Ignore this comment if this PR does not change the documentation.
  • The preview is updated when a new commit is pushed to this PR.
  • This comment was created by this workflow run.
  • The documentation was built by this workflow run.

Copy link
Collaborator

@B-Step62 B-Step62 left a comment

Choose a reason for hiding this comment

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

LGTM!

@TomeHirata TomeHirata added this pull request to the merge queue Feb 19, 2026
Merged via the queue into mlflow:master with commit 4e8cfa1 Feb 19, 2026
50 of 52 checks passed
@TomeHirata TomeHirata deleted the fix/path-traversal-windows branch February 19, 2026 08:47
daniellok-db pushed a commit to daniellok-db/mlflow that referenced this pull request Feb 20, 2026
…#20924)

Signed-off-by: Tomu Hirata <tomu.hirata@gmail.com>
Signed-off-by: TomuHirata <tomu.hirata@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
daniellok-db pushed a commit that referenced this pull request Feb 20, 2026
Signed-off-by: Tomu Hirata <tomu.hirata@gmail.com>
Signed-off-by: TomuHirata <tomu.hirata@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/tracking Tracking service, tracking client APIs, autologging rn/bug-fix Mention under Bug Fixes in Changelogs. size/S Small PR (10-49 LoC) team-review Trigger a team review request v3.10.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants