Hugging Face datasets versions up to and including 5.1.0 allow arbitrary Python code execution when loading attacker-controlled pickle files through the deprecated but still registered pandas packaged builder.
The builder resolves caller-supplied data_files , opens each file as bytes, and passes the file object directly to pandas.read_pickle() before converting the result to an Arrow table:
Python pickle deserialization can execute attacker-selected code. When a victim loads a malicious pickle-backed dataset with datasets.load_dataset("pandas", data_files=...) , the payload executes with the victim process's privileges before Arrow conversion or feature validation.
An attacker who can cause a victim to load an attacker-controlled pickle through the pandas builder may execute arbitrary Python code in the victim process.
This can affect data analysis, machine learning, and automation workflows that load datasets from untrusted projects, repositories, downloads, or shared files. The attacker does not need privileges in the victim environment, but the victim must load the malicious dataset, consistent with the report's user-interaction requirement ( UI:R ).
Depending on the local environment, this may allow:
Reading files, environment variables, and application secrets accessible to the process.
Modifying files or data used by the victim's workflow.
Running Python operations or local programs with the process's privileges.
Disrupting data processing or exhausting available resources.
The vulnerable path is the pandas packaged builder:
The PoC creates a pickle object whose __reduce__() method specifies a callable that writes a harmless local marker file and returns a valid pandas.DataFrame . During deserialization, that callable executes before the builder converts the returned DataFrame to an Arrow table. Dataset loading then completes normally and returns one row.
The runner invokes the real datasets.load_dataset() API from the installed package. A fresh local cache and removal of the marker ensure that the saved result demonstrates execution during dataset loading.
Deprecating the builder or validating the returned DataFrame does not prevent execution during unpickling. The pandas documentation also warns against loading pickle data from untrusted sources .
run_poc.py generates attacker-controlled.pkl , loads it through the pandas builder, and records execution evidence.
Run in a local test environment only. To reproduce the version shown in the saved evidence on Windows:
The included requirements.txt currently specifies datasets<=5.0.1 . It can be installed with python -m pip install -r requirements.txt to test that earlier range, but it does not select the 5.1.0 installation used in the saved evidence. The explicit pin above reproduces that installation's datasets version.
Expected evidence on the demonstrated vulnerable version:
The important evidence is that the marker is absent before load_dataset() , appears during loading, and contains the expected string while dataset loading completes successfully and returns the expected row.
The payload's execution effect is a local marker-file write:
The runner also writes the generated pickle, cache, and evidence files. Each run replaces attacker-controlled.pkl , marker.txt , cache/ , and evidence/ in the PoC directory; preserve existing evidence before rerunning it.
The narrow fix replaces the entire body of Pandas._generate_tables() with an unconditional error before any file is opened or passed to pandas.read_pickle() :
The error explains the pickle execution risk and directs callers to Parquet, Arrow, CSV, JSON, or Dataset.from_pandas() for an existing DataFrame. This blocks the reported code-execution path for every filename, including trusted pickles; it does not attempt to determine which pickle files are trustworthy.
The builder remains registered and can still be constructed through load_dataset_builder("pandas", ...) or Pandas(...) . File resolution and downloads may happen before table generation fails. With streaming, the error occurs when the dataset is iterated. A compatible prepared Arrow cache can still be reused without calling _generate_tables() or unpickling the input. Changing the builder source changes its hash, so older caches may no longer match automatically. This patch does not reject the builder name in load.py .
For example, load Parquet through its dedicated builder:
Regression tests cover fresh loading, streaming iteration, direct table generation, builder construction, prepared Arrow cache reuse, and supported replacement formats. They verify that pandas.read_pickle() is never reached and that direct table generation does not open files. Checking an object's type after unpickling is too late. Renaming a file, emitting a warning, or converting an untrusted pickle to another format by first unpickling it does not address the execution risk.
See fix.md for the narrow patch, migration guidance, and verification commands. The patch is applied to this checkout's source; existing installed packages must be patched or replaced separately. This repository links the related upstream pull request below; a confirmed fixed release is not documented here.
Discovered and reported by Sai Teja Erukude .
Disclosure was coordinated through VulnCheck.
CVE Record: CVE-2026-57845
Hugging Face datasets repository
Hugging Face datasets PR #8879
Pandas builder source at datasets 5.1.0
pandas.read_pickle documentation
Python pickle security warning
CWE-502: Deserialization of Untrusted Data
The full story
This article is one source in a clustered incident — the cluster page carries the summary, timeline and every other outlet covering it.
