CVE-2023-1176 (published 2023-03-24T15:15Z)

Absolute Path Traversal in GitHub repository mlflow/mlflow prior to 2.2.2.

CVSS v3 base score: 3.3, LOW (CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:L/I:N/A:N)

Weakness information:
cwe_id: CWE-36
cwe_name: Absolute Path Traversal
description: The product uses external input to construct a pathname that should be within a restricted directory, but it does not properly neutralize absolute path sequences such as "/abs/path" that can resolve to a location that is outside of that directory.
extended_description: This allows attackers to traverse the file system to access files or directories that are outside of the restricted directory.
         

Fix information:
repo_url: https://github.com/mlflow/mlflow
commit_details: repo_url: https://github.com/mlflow/mlflow
author: Harutaka Kawamura
author_date: 2023-02-25 14:22:33+09:00
msg: Prevent registered model name from containing path separator (#7892)

Signed-off-by: harupy <hkawamura0130@gmail.com>
repository: repo_url: https://github.com/mlflow/mlflow
repo_name: mlflow/mlflow
description: Open source platform for the machine learning lifecycle
repo_language: Python
owner: mlflow
file_changes: filename: file_store.py
change_type: ModificationType.MODIFY
diff: @@ -37,7 +37,7 @@ from mlflow.utils.string_utils import is_string_type
 from mlflow.utils.validation import (
     _validate_registered_model_tag,
     _validate_model_version_tag,
-    _validate_model_name,
+    _validate_model_name as _original_validate_model_name,
     _validate_model_version,
     _validate_tag_name,
 )
@@ -56,6 +56,7 @@ from mlflow.utils.file_utils import (
     make_containing_dirs,
     list_all,
     local_file_uri_to_path,
+    contains_path_separator,
 )
 from mlflow.utils.time_utils import get_current_time_millis
 
@@ -67,6 +68,15 @@ def _default_root_dir():
     return get_env(_REGISTRY_DIR_ENV_VAR) or os.path.abspath(DEFAULT_LOCAL_FILE_AND_ARTIFACT_PATH)
 
 
+def _validate_model_name(name):
+    _original_validate_model_name(name)
+    if contains_path_separator(name):
+        raise MlflowException(
+            f"Invalid name: '{name}'. Registered model name cannot contain path separator",
+            INVALID_PARAMETER_VALUE,
+        )
+
+
 class FileStore(AbstractStore):
     MODELS_FOLDER_NAME = "models"
     META_DATA_FILE_NAME = "meta.yaml"

programming_language: Python
filename: file_utils.py
change_type: ModificationType.MODIFY
diff: @@ -711,3 +711,10 @@ def shutil_copytree_without_file_permissions(src_dir, dst_dir):
             relative_file_path = os.path.relpath(file_path, src_dir)
             abs_file_path = os.path.join(dst_dir, relative_file_path)
             shutil.copyfile(file_path, abs_file_path)
+
+
+def contains_path_separator(path):
+    """
+    Returns True if a path contains a path separator, False otherwise.
+    """
+    return any((sep in path) for sep in (os.path.sep, os.path.altsep) if sep is not None)

programming_language: Python
filename: test_file_store.py
change_type: ModificationType.MODIFY
diff: @@ -62,6 +62,14 @@ def test_create_registered_model(store):
     assert model.tags == {}
 
 
+def test_create_registered_model_with_name_that_looks_like_path(store, tmp_path):
+    name = str(tmp_path.joinpath("test"))
+    with pytest.raises(
+        MlflowException, match=r"Registered model name cannot contain path separator"
+    ):
+        store.get_registered_model(name)
+
+
 def _verify_registered_model(fs, name, rm_data):
     rm = fs.get_registered_model(name)
     assert rm.name == name

programming_language: Python