Hugging Face Datasets Flaw Lets Malicious Pickle Files Run Code

The deprecated pandas builder can execute code from an untrusted pickle file. A proposed fix is still awaiting review
Hugging Face Datasets Flaw Lets Malicious Pickle Files Run Code
Table of Contents
    Add a header to begin generating the table of contents

    A flaw in Hugging Face’s datasets library lets a malicious pickle file run Python code when it is loaded through the library’s deprecated pandas builder. AI security researcher Sai Teja Erukude discovered and reported the issue, published a demonstration, and submitted a patch with regression tests. The patch has not been merged.

    An attacker would need to get someone to load a crafted pickle through the affected builder. Installing datasets or downloading a file is not enough. Erukude said he has seen no evidence of exploitation beyond his controlled test.

    How the datasets pandas builder executes a pickle payload

    The builder is deprecated, but it is still present in that release. Its deprecation warning does not stop the pickle from being opened.

    Which Hugging Face datasets workflows can trigger the flaw

    One plausible scenario involves a researcher downloading a dataset and notebook from an external repository, then running the notebook to reproduce an experiment. If the notebook loads the supplied pickle through the pandas builder, the file can run code with the researcher’s Python process privileges. A legacy pipeline that accepts pickle files from outside parties could face the same problem. These are examples of possible exposure, not observed attacks.

    The code runs with whatever access the loading process already has. That could include files and credentials available to the process, but the demonstration did not attempt to steal data or gain higher privileges. Nor did it show a compromise of Hugging Face’s hosted services.

    Pickle proof of concept shows code execution during loading

    The crafted pickle writes a harmless marker file and returns a valid DataFrame. In the test, the marker appeared while datasets loaded the file, and loading completed with the expected row. The result confirms code execution through this builder even when the dataset appears to load normally.

    His test used a local file. It did not demonstrate how an attacker would deliver one to a victim. The attack would still depend on a person or application choosing to load untrusted pickle content through the affected path.

    The proposed Hugging Face datasets patch remains open

    Validation after unpickling would come too late because code may already have run. A warning or an expected filename would not solve that problem. The proposed patch still allows file resolution and downloads before the new guard is reached; it targets the unsafe deserialization call.

    How to reduce exposure to the datasets pickle flaw

    Teams should check for code that loads externally supplied files through the pandas builder, including load_dataset(“pandas”, data_files=…). They should stop using that path for untrusted pickle files.

    Trusted producers can export data as Parquet, Arrow, CSV, or JSON for use with the corresponding loader. An existing DataFrame that was constructed safely can be passed to Dataset.from_pandas(). Opening an untrusted pickle to convert it to another format would expose the converter to the same risk.

    If a legacy workflow cannot immediately stop using pickle, teams should limit inputs to trusted producers, check provenance and integrity, and isolate the unpickling process from sensitive files, production credentials, and unnecessary network access. These measures can limit exposure, but they cannot make a malicious pickle safe. Teams may also test and deploy the proposed patch while they wait for an upstream release.

    Conclusion

    CVE-2026-57845 turns a specific data-loading choice into a code-execution risk. The demonstrated path requires untrusted pickle content to reach the deprecated pandas builder; it is not triggered by installing datasets or downloading a file. Until a fix is released, teams using that builder should move to other file formats where possible and isolate any unavoidable pickle loading. A dataset that loads successfully can still have run code before it returned a row.

    Related Posts