VYPR
High severity7.8NVD Advisory· Published May 3, 2024· Updated Apr 15, 2026

CVE-2024-34072

CVE-2024-34072

Description

sagemaker-python-sdk is a library for training and deploying machine learning models on Amazon SageMaker. The sagemaker.base_deserializers.NumpyDeserializer module before v2.218.0 allows potentially unsafe deserialization when untrusted data is passed as pickled object arrays. This consequently may allow an unprivileged third party to cause remote code execution, denial of service, affecting both confidentiality and integrity. Users are advised to upgrade to version 2.218.0. Users unable to upgrade should not pass pickled numpy object arrays which originated from an untrusted source, or that could have been tampered with. Only pass pickled numpy object arrays from trusted sources.

Affected packages

Versions sourced from the GitHub Security Advisory.

PackageAffected versionsPatched versions
sagemakerPyPI
< 2.218.02.218.0

Patches

2
72e0c9712aec

feature: set default allow_pickle param to False (#4557)

https://github.com/aws/sagemaker-python-sdkASHWIN KRISHNAApr 29, 2024via ghsa
2 files changed · +16 4
  • src/sagemaker/base_deserializers.py+14 3 modified
    @@ -196,14 +196,14 @@ class NumpyDeserializer(SimpleBaseDeserializer):
         single array.
         """
     
    -    def __init__(self, dtype=None, accept="application/x-npy", allow_pickle=True):
    +    def __init__(self, dtype=None, accept="application/x-npy", allow_pickle=False):
             """Initialize a ``NumpyDeserializer`` instance.
     
             Args:
                 dtype (str): The dtype of the data (default: None).
                 accept (union[str, tuple[str]]): The MIME type (or tuple of allowable MIME types) that
                     is expected from the inference endpoint (default: "application/x-npy").
    -            allow_pickle (bool): Allow loading pickled object arrays (default: True).
    +            allow_pickle (bool): Allow loading pickled object arrays (default: False).
             """
             super(NumpyDeserializer, self).__init__(accept=accept)
             self.dtype = dtype
    @@ -227,10 +227,21 @@ def deserialize(self, stream, content_type):
                 if content_type == "application/json":
                     return np.array(json.load(codecs.getreader("utf-8")(stream)), dtype=self.dtype)
                 if content_type == "application/x-npy":
    -                return np.load(io.BytesIO(stream.read()), allow_pickle=self.allow_pickle)
    +                try:
    +                    return np.load(io.BytesIO(stream.read()), allow_pickle=self.allow_pickle)
    +                except ValueError as ve:
    +                    raise ValueError(
    +                        "Please set the param allow_pickle=True \
    +                        to deserialize pickle objects in NumpyDeserializer"
    +                    ).with_traceback(ve.__traceback__)
                 if content_type == "application/x-npz":
                     try:
                         return np.load(io.BytesIO(stream.read()), allow_pickle=self.allow_pickle)
    +                except ValueError as ve:
    +                    raise ValueError(
    +                        "Please set the param allow_pickle=True \
    +                        to deserialize pickle objectsin NumpyDeserializer"
    +                    ).with_traceback(ve.__traceback__)
                     finally:
                         stream.close()
             finally:
    
  • tests/unit/sagemaker/deserializers/test_deserializers.py+2 1 modified
    @@ -142,7 +142,8 @@ def test_numpy_deserializer_from_npy(numpy_deserializer):
         assert np.array_equal(array, result)
     
     
    -def test_numpy_deserializer_from_npy_object_array(numpy_deserializer):
    +def test_numpy_deserializer_from_npy_object_array():
    +    numpy_deserializer = NumpyDeserializer(allow_pickle=True)
         array = np.array([{"a": "", "b": ""}, {"c": "", "d": ""}])
         stream = io.BytesIO()
         np.save(stream, array)
    

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

5

News mentions

0

No linked articles in our index yet.