/

CVE-2026-57845

Severity:

HIGH RISK

(8.8)

Unsafe Deserialization (CWE-502) in Hugging Face Datasets

CVE-2026-57845

Awaiting Analysis

Vulnerability type

Category:

Unsafe Deserialization

CWE:

CWE-502

Impact:

Arbitrary Python Code Execution

Severity:

HIGH RISK

(8.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Hugging Face Datasets can insecurely deserialize attacker-controlled pickle files through its deprecated pandas packaged builder. If a victim loads a malicious pickle-backed dataset with the pandas builder, embedded code may execute with the privileges of the victim process.

Hugging Face Datasets can insecurely deserialize attacker-controlled pickle files through its deprecated pandas packaged builder. If a victim loads a malicious pickle-backed dataset with the pandas builder, embedded code may execute with the privileges of the victim process.

Affected context

The vulnerability occurs in deployments using the pandas packaged builder and supplying dataset files that are processed through Pandas read_pickle() during table generation. Risk is present when an attacker can provide or influence a pickle-backed dataset and a victim or automated service invokes datasets.load_dataset("pandas", data_files=...) without independent trust validation.

The vulnerability occurs in deployments using the pandas packaged builder and supplying dataset files that are processed through Pandas read_pickle() during table generation. Risk is present when an attacker can provide or influence a pickle-backed dataset and a victim or automated service invokes datasets.load_dataset("pandas", data_files=...) without independent trust validation.

Exploit preconditions

  • Attack surface: Dataset ingestion through the pandas packaged builder
  • Required access: Ability to supply, replace, or influence a dataset file loaded by the victim process
  • Trigger point: Processing the file through Pandas._generate_tables and pandas.read_pickle()
  • Why exploitation is possible: Pickle deserialization can invoke attacker-controlled object behavior, including __reduce__ logic, without validating the file as data-only content
  • Attack surface: Dataset ingestion through the pandas packaged builder
  • Required access: Ability to supply, replace, or influence a dataset file loaded by the victim process
  • Trigger point: Processing the file through Pandas._generate_tables and pandas.read_pickle()
  • Why exploitation is possible: Pickle deserialization can invoke attacker-controlled object behavior, including __reduce__ logic, without validating the file as data-only content

Why this happens

The underlying bug is the use of Python pickle deserialization on an untrusted dataset file. Pickle is capable of reconstructing arbitrary Python objects and invoking embedded reduction functions during loading, meaning that parsing is not limited to passive data conversion. This behavior maps to CWE-502: Deserialization of Untrusted Data, because attacker-controlled serialized content is treated as trusted executable object state.

The underlying bug is the use of Python pickle deserialization on an untrusted dataset file. Pickle is capable of reconstructing arbitrary Python objects and invoking embedded reduction functions during loading, meaning that parsing is not limited to passive data conversion. This behavior maps to CWE-502: Deserialization of Untrusted Data, because attacker-controlled serialized content is treated as trusted executable object state.

Potential impact

  • Arbitrary Python code may execute in the victim process
  • Attackers could access data, credentials, or files available to that process
  • The affected workload could be modified, disrupted, or used for persistence
  • Compromised services could facilitate lateral movement depending on runtime permissions
  • Dataset integrity and downstream machine-learning workflows could be affected
  • Arbitrary Python code may execute in the victim process
  • Attackers could access data, credentials, or files available to that process
  • The affected workload could be modified, disrupted, or used for persistence
  • Compromised services could facilitate lateral movement depending on runtime permissions
  • Dataset integrity and downstream machine-learning workflows could be affected

General mitigation guidance

Mitigation generally focuses on eliminating unsafe deserialization of untrusted dataset content and reducing trust in externally supplied files.

Common defensive patterns include:

  • Prefer data-only formats and parsers that do not execute object reconstruction logic
  • Avoid pickle-backed dataset ingestion for untrusted or externally sourced files
  • Enforce explicit file-format allowlists and content validation before processing
  • Separate dataset acquisition from high-privilege application workloads
  • Run ingestion processes with least-privilege filesystem, network, and credential access
  • Apply sandboxing or isolation when legacy serialized formats cannot be removed
  • Require provenance, integrity verification, and review for dataset artifacts

Mitigation generally focuses on eliminating unsafe deserialization of untrusted dataset content and reducing trust in externally supplied files.

Common defensive patterns include:

  • Prefer data-only formats and parsers that do not execute object reconstruction logic
  • Avoid pickle-backed dataset ingestion for untrusted or externally sourced files
  • Enforce explicit file-format allowlists and content validation before processing
  • Separate dataset acquisition from high-privilege application workloads
  • Run ingestion processes with least-privilege filesystem, network, and credential access
  • Apply sandboxing or isolation when legacy serialized formats cannot be removed
  • Require provenance, integrity verification, and review for dataset artifacts

How teams detect issues like this

Organizations can identify similar risks through:

  • Static analysis rules for pickle, pandas.read_pickle(), and equivalent unsafe deserialization APIs
  • Code review checks for dataset loaders that accept attacker-controlled or externally sourced files
  • Dependency and configuration policies that flag deprecated packaged builders or pickle-based ingestion
  • Runtime monitoring for unexpected child processes, file access, or network activity during dataset loading
  • CI policy enforcement requiring approved data formats and documented trust boundaries
  • Automated security review tools that detect unsafe deserialization patterns and untrusted input flows

Organizations can identify similar risks through:

  • Static analysis rules for pickle, pandas.read_pickle(), and equivalent unsafe deserialization APIs
  • Code review checks for dataset loaders that accept attacker-controlled or externally sourced files
  • Dependency and configuration policies that flag deprecated packaged builders or pickle-based ingestion
  • Runtime monitoring for unexpected child processes, file access, or network activity during dataset loading
  • CI policy enforcement requiring approved data formats and documented trust boundaries
  • Automated security review tools that detect unsafe deserialization patterns and untrusted input flows

Sources

SourceLink
github.comgithub.com/SaiTeja-Erukude/CVE-2026-57845-hf-datasets-rce
github.comgithub.com/huggingface/datasets/pull/8879
vulncheck.comvulncheck.com/advisories/hugging-face-datasets-pickle-deserialization-rce-via-pandas-builder

Frequently asked

questions

It can be exploitable through a remote or indirect delivery path when an attacker can cause a victim service, job, or user to load a malicious pickle-backed dataset. The vulnerability itself is triggered during local processing of the supplied file.

An attacker generally needs the ability to provide, replace, or influence a dataset file that the victim later loads with the pandas builder. Direct access to the victim host is not necessarily required if datasets are obtained from an attacker-controlled location or workflow.

The safest pattern is to avoid pickle deserialization for untrusted data and use a data-only format with strict validation, provenance checks, and an explicit allowlist of accepted file types.

Treat serialized datasets as executable content, isolate ingestion workloads, enforce least privilege, scan code for unsafe deserialization APIs, and require integrity and provenance controls for external artifacts.

It can be exploitable through a remote or indirect delivery path when an attacker can cause a victim service, job, or user to load a malicious pickle-backed dataset. The vulnerability itself is triggered during local processing of the supplied file.

An attacker generally needs the ability to provide, replace, or influence a dataset file that the victim later loads with the pandas builder. Direct access to the victim host is not necessarily required if datasets are obtained from an attacker-controlled location or workflow.

The safest pattern is to avoid pickle deserialization for untrusted data and use a data-only format with strict validation, provenance checks, and an explicit allowlist of accepted file types.

Treat serialized datasets as executable content, isolate ingestion workloads, enforce least privilege, scan code for unsafe deserialization APIs, and require integrity and provenance controls for external artifacts.

Find out what's already
exploitable in your codebase.