sassoftware / python-sasctl

Audit required: Use of pickle module BAN-B301
Security
Major
10 months ago5 years old
Pickle and modules that wrap it can be unsafe when used to deserialize untrusted data, possible security issue.
 98                pzmm_pickle_path.rename(Path(pickle_path) / (sanitized_prefix + PICKLE))
 99            else:
100                with open(ml_pickle_path, "rb") as pickle_file:
101                    return {sanitized_prefix + PICKLE: pickle.load(pickle_file)}102        else:
103            # For all other model types
104            if not is_h2o_model:
Pickle and modules that wrap it can be unsafe when used to deserialize untrusted data, possible security issue.
104        model = pickle.loads(in_file)
105    else:
106        # Assume a file object containing the pickled object
107        model = pickle.load(in_file)108
109    # Verify model is a valid type
110    parser = _check_type(model)
Pickle and modules that wrap it can be unsafe when used to deserialize untrusted data, possible security issue.
101
102    elif isinstance(in_file, bytes):
103        # Assume byte string is the actual pickled bytes
104        model = pickle.loads(in_file)105    else:
106        # Assume a file object containing the pickled object
107        model = pickle.load(in_file)
Pickle and modules that wrap it can be unsafe when used to deserialize untrusted data, possible security issue.
 97        else:
 98            # Read pickled files
 99            with open(in_file, "rb") as f:
100                model = pickle.load(f)101
102    elif isinstance(in_file, bytes):
103        # Assume byte string is the actual pickled bytes
Pickle and modules that wrap it can be unsafe when used to deserialize untrusted data, possible security issue.
16        global model
17    except NameError:
18        with open(Path(settings.pickle_path) / "RandomForest.pickle", "rb") as pickle_model:
19                model = pickle.load(pickle_model)20
21
22