CVE-2023-2800: PYSEC-2023-299 - Insecure Temporary File in GitHub repository huggingface/transformers prior to 4.30.0.

CVE-2023-2800 · Severity: low · CVSS 3.1 · Published 2023-05-18

Hugging Face transformers is a widely-used Python library for building machine learning models, particularly for natural language processing tasks. The library uses an insecure method to create temporary files during model loading operations, which could allow local attackers to predict temporary file locations and potentially intercept or modify model data before it is processed.

Technologies: Hugging Face Transformers, transformers (PyPI). Vendors: Hugging Face, PyPI.

Quick answers

Is CVE-2023-2800 exploited in the wild?
No. Junglewise Threat Intelligence has no report of CVE-2023-2800 being exploited in the wild.
How severe is CVE-2023-2800?
Low severity, with a CVSS score of 3.1, published 18 May 2023.
Which products and versions are affected?
Hugging Face Transformers before 4.30.0; transformers (PyPI) GIT:introduced=0,fixed=80ca92470938bbcc348e2d9cf4734c7c25cb1c43|ECOSYSTEM:introduced=0,fixed=4.30.0.
Is there a fix for CVE-2023-2800?
Yes. transformers (PyPI): upgrade to 4.30.0 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
How is CVE-2023-2800 attacked?
It is attacked with local access.
Am I affected by CVE-2023-2800?
Check whether you run Hugging Face Transformers or transformers (PyPI) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

How to fix

  • transformers (PyPI): upgrade to 4.30.0 or later
    pip install "transformers>=4.30.0"

Technical details

The vulnerability stems from the use of the deprecated `tempfile.mktemp()` function, which has a known insecure design (CWE-377). The function generates predictable temporary file names without actually creating the files, allowing race conditions where an attacker can create files at those locations before the legitimate code does. The vulnerability is present in model loading code and affects all versions prior to 4.30.0. The fix replaces `mktemp()` with the secure `mkstemp()` function, which atomically creates temporary files with restricted permissions. An attacker with local system access could exploit this during model loading operations.

Affected products

  • Hugging Face transformers before 4.30.0

Identifiers

  • CVE-2023-2800
  • GHSA-282v-666c-3fvg
  • PYSEC-2023-299

Timeline

  • 2023-05-18: disclosed: Advisory published
  • 2023-05-16: patched: Fix merged into main branch via commit 80ca92470938bbcc348e2d9cf4734c7c25cb1c43
  • 2023-05-30: other: Version 4.30.0 released with fix

References

This page as Markdown. Free to reuse under CC BY 4.0 with a link back.