From db177627d97c96b9c44abfa0b569c33da3cc369a Mon Sep 17 00:00:00 2001 From: "d.a.bunin" Date: Fri, 4 Aug 2023 12:03:06 +0300 Subject: [PATCH 1/3] docs: add warning about using dill in loading --- docs/source/conf.py | 4 ++++ etna/core/mixins.py | 6 ++++++ etna/core/utils.py | 6 ++++++ etna/ensembles/mixins.py | 6 ++++++ etna/pipeline/mixins.py | 6 ++++++ 5 files changed, 28 insertions(+) diff --git a/docs/source/conf.py b/docs/source/conf.py index a0ade5cd5..e7fc2d5fe 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -80,6 +80,10 @@ autodoc_typehints_description_target = "all" add_module_names = False +autodoc_default_options = { + "inherited-members": True, +} + # Add any paths that contain templates here, relative to this directory. templates_path = ["_templates"] diff --git a/etna/core/mixins.py b/etna/core/mixins.py index dca2c2064..dc3cd4797 100644 --- a/etna/core/mixins.py +++ b/etna/core/mixins.py @@ -276,6 +276,12 @@ def _load_state(cls, archive: zipfile.ZipFile) -> Self: def load(cls, path: pathlib.Path) -> Self: """Load an object. + Warning + ------- + This method uses :py:mod:`dill` module which is not secure. + It is possible to construct malicious data which will execute arbitrary code during loading. + Never load data that could have come from an untrusted source, or that could have been tampered with. + Parameters ---------- path: diff --git a/etna/core/utils.py b/etna/core/utils.py index 0dc2ee29b..a76ce004c 100644 --- a/etna/core/utils.py +++ b/etna/core/utils.py @@ -13,6 +13,12 @@ def load(path: pathlib.Path, **kwargs: Any) -> Any: """Load saved object by path. + Warning + ------- + This method uses :py:mod:`dill` module which is not secure. + It is possible to construct malicious data which will execute arbitrary code during loading. + Never load data that could have come from an untrusted source, or that could have been tampered with. + Parameters ---------- path: diff --git a/etna/ensembles/mixins.py b/etna/ensembles/mixins.py index 00fb4c9e7..2673c361e 100644 --- a/etna/ensembles/mixins.py +++ b/etna/ensembles/mixins.py @@ -116,6 +116,12 @@ def save(self, path: pathlib.Path): def load(cls, path: pathlib.Path, ts: Optional[TSDataset] = None) -> Self: """Load an object. + Warning + ------- + This method uses :py:mod:`dill` module which is not secure. + It is possible to construct malicious data which will execute arbitrary code during loading. + Never load data that could have come from an untrusted source, or that could have been tampered with. + Parameters ---------- path: diff --git a/etna/pipeline/mixins.py b/etna/pipeline/mixins.py index b9d33b613..eccba1b66 100644 --- a/etna/pipeline/mixins.py +++ b/etna/pipeline/mixins.py @@ -207,6 +207,12 @@ def save(self, path: pathlib.Path): def load(cls, path: pathlib.Path, ts: Optional[TSDataset] = None) -> Self: """Load an object. + Warning + ------- + This method uses :py:mod:`dill` module which is not secure. + It is possible to construct malicious data which will execute arbitrary code during loading. + Never load data that could have come from an untrusted source, or that could have been tampered with. + Parameters ---------- path: From be92d119ec5c4a147cca0c11db919ec9e9acefea Mon Sep 17 00:00:00 2001 From: "d.a.bunin" Date: Fri, 4 Aug 2023 12:05:17 +0300 Subject: [PATCH 2/3] chore: update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 05345e9df..fe3c2b9a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Unify errors, warnings and checks in models ([#1312](https://github.com/tinkoff-ai/etna/pull/1312)) - Remove upper limitation on version of numba ([#1321](https://github.com/tinkoff-ai/etna/pull/1321)) - Optimize `TSDataset.describe` and `TSDataset.info` by vectorization ([#1344](https://github.com/tinkoff-ai/etna/pull/1344)) +- Add documentation warning about using dill during loading ([#1346](https://github.com/tinkoff-ai/etna/pull/1346)) ### Fixed - Pipeline ensembles fail in `etna forecast` CLI ([#1331](https://github.com/tinkoff-ai/etna/pull/1331)) From 1d86a54a7a9feb73298431d0eef2e942160b4181 Mon Sep 17 00:00:00 2001 From: "d.a.bunin" Date: Mon, 7 Aug 2023 17:23:04 +0300 Subject: [PATCH 3/3] docs: add warning to PickleSerializable and ParallelLocalRunner --- etna/auto/runner/local.py | 4 ++++ etna/experimental/classification/base.py | 9 ++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/etna/auto/runner/local.py b/etna/auto/runner/local.py index 8332ce128..1679d8796 100644 --- a/etna/auto/runner/local.py +++ b/etna/auto/runner/local.py @@ -29,6 +29,10 @@ class ParallelLocalRunner(AbstractRunner): Global objects behavior could be different while parallel usage because platform dependent new process start. Be sure that new process is started with ``fork`` via ``multiprocessing.set_start_method``. If it's not possible you should try define all globals before ``if __name__ == "__main__"`` scope. + + Warning + ------- + This class uses :py:mod:`dill` module during serialization which might be not secure. """ def __init__( diff --git a/etna/experimental/classification/base.py b/etna/experimental/classification/base.py index f613b3937..7762ad658 100644 --- a/etna/experimental/classification/base.py +++ b/etna/experimental/classification/base.py @@ -11,7 +11,14 @@ def dump(self, path: str, *args, **kwargs): @staticmethod def load(path: str, *args, **kwargs): - """Load the object.""" + """Load the object. + + Warning + ------- + This method uses :py:mod:`dill` module which is not secure. + It is possible to construct malicious data which will execute arbitrary code during loading. + Never load data that could have come from an untrusted source, or that could have been tampered with. + """ with open(path, "rb") as file: clf = pickle.load(file, *args, **kwargs) return clf