VYPR
High severityNVD Advisory· Published Apr 21, 2023· Updated Feb 4, 2025

Arbitrary File Write when Extracting a Remotely retrieved Tarball in mindsdb/mindsdb

CVE-2023-30620

Description

mindsdb is a Machine Learning platform to help developers build AI solutions. In affected versions an unsafe extraction is being performed using tarfile.extractall() from a remotely retrieved tarball. Which may lead to the writing of the extracted files to an unintended location. Sometimes, the vulnerability is called a TarSlip or a ZipSlip variant. An attacker may leverage this vulnerability to overwrite any local file which the server process has access to. There is no risk of file exposure with this vulnerability. This issue has been addressed in release 23.2.1.0 . Users are advised to upgrade. There are no known workarounds for this vulnerability.

Affected packages

Versions sourced from the GitHub Security Advisory.

PackageAffected versionsPatched versions
mindsdbPyPI
< 23.2.1.023.2.1.0

Affected products

1

Patches

1
4419b0f0019c

Use safe extract to prevent CVE-2007-4559 bug

https://github.com/mindsdb/mindsdbzoranFeb 16, 2023via ghsa
2 files changed · +17 2
  • mindsdb/api/http/namespaces/file.py+2 2 modified
    @@ -9,7 +9,7 @@
     import requests
     
     from mindsdb.utilities import log
    -from mindsdb.api.http.utils import http_error
    +from mindsdb.api.http.utils import http_error, safe_extract
     from mindsdb.api.http.namespaces.configs.files import ns_conf
     from mindsdb.utilities.config import Config
     from mindsdb.utilities.context import context as ctx
    @@ -134,7 +134,7 @@ def on_file(file):
                         f.extractall(temp_dir_path)
                 elif lp.endswith('.tar.gz'):
                     with tarfile.open(file_path) as f:
    -                    f.extractall(temp_dir_path)
    +                    safe_extract(f, temp_dir_path)
                 os.remove(file_path)
                 files = os.listdir(temp_dir_path)
                 if len(files) != 1:
    
  • mindsdb/api/http/utils.py+15 0 modified
    @@ -1,4 +1,5 @@
     import json
    +import os
     
     from flask import Response
     
    @@ -22,3 +23,17 @@ def http_error(status_code, title, detail=''):
                 'Content-Type': 'application/problem+json'
             }
         )
    +
    +def __is_within_directory(directory, target):
    +    abs_directory = os.path.abspath(directory)
    +    abs_target = os.path.abspath(target)
    +    prefix = os.path.commonprefix([abs_directory, abs_target])
    +    return prefix == abs_directory
    +
    +def safe_extract(tar, path=".", members=None, *, numeric_owner=False):
    +    for member in tar.getmembers():
    +        member_path = os.path.join(path, member.name)
    +        if not __is_within_directory(path, member_path):
    +            raise Exception("Attempted Path Traversal in Tar File")
    +    tar.extractall(path, members, numeric_owner) 
    +
    

Vulnerability mechanics

Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.

References

7

News mentions

0

No linked articles in our index yet.