fix(io): drop pickle dispatch from PandasDataFrame.from_sample#5613
Open
ibondarenko1 wants to merge 1 commit into
Open
fix(io): drop pickle dispatch from PandasDataFrame.from_sample#5613ibondarenko1 wants to merge 1 commit into
ibondarenko1 wants to merge 1 commit into
Conversation
PandasDataFrame.from_sample(str_path) dispatches on file extension
and maps '.pickle' to pd.read_pickle, which deserializes arbitrary
Python objects. A bento author who points from_sample at an untrusted
pickle file (HuggingFace cache, shared NFS, etc.) executes arbitrary
Python at descriptor construction.
This is build-time, not runtime. SECURITY.md's pickle exception
('pickle-related vulnerabilities in the runner service or dependency
service') does not cover this build-time path.
The from_sample string overload is already deprecated. Authors who
want pickle can pd.read_pickle() explicitly and pass the resulting
DataFrame.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
PandasDataFrame.from_sample(str_path)dispatches on file extension and maps.pickletopd.read_pickle. A bento author who pointsfrom_sampleat an untrusted pickle file (HuggingFace cache, shared NFS, etc.) executes arbitrary Python at descriptor construction.This is build-time, not runtime.
SECURITY.md's pickle exception ("pickle-related vulnerabilities in the runner service or dependency service") does not cover this build-time path.What
Delete one line from the dispatch table at
_internal/io_descriptors/pandas.py:417:The
from_samplestring overload is already deprecated. Authors who want pickle canpd.read_pickle()explicitly.Impact
Bentos calling
PandasDataFrame.from_sample("file.pickle")will hitInvalidArgument("Unsupported sample '...' format."). Acceptable: the function is already deprecated for string input.Testing
pytest tests/unit/_internal/io_descriptors/test_pandas.py