Skip to content

fix(io): drop pickle dispatch from PandasDataFrame.from_sample#5613

Open
ibondarenko1 wants to merge 1 commit into
bentoml:mainfrom
ibondarenko1:fix/pandas-from-sample-pickle
Open

fix(io): drop pickle dispatch from PandasDataFrame.from_sample#5613
ibondarenko1 wants to merge 1 commit into
bentoml:mainfrom
ibondarenko1:fix/pandas-from-sample-pickle

Conversation

@ibondarenko1
Copy link
Copy Markdown

Why

PandasDataFrame.from_sample(str_path) dispatches on file extension and maps .pickle to pd.read_pickle. 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.

What

Delete one line from the dispatch table at _internal/io_descriptors/pandas.py:417:

"pickle": "read_pickle",

The from_sample string overload is already deprecated. Authors who want pickle can pd.read_pickle() explicitly.

Impact

Bentos calling PandasDataFrame.from_sample("file.pickle") will hit InvalidArgument("Unsupported sample '...' format."). Acceptable: the function is already deprecated for string input.

Testing

  • pytest tests/unit/_internal/io_descriptors/test_pandas.py

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.
@ibondarenko1 ibondarenko1 requested a review from a team as a code owner May 16, 2026 00:57
@ibondarenko1 ibondarenko1 requested review from bojiang and removed request for a team May 16, 2026 00:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant