CVE-2026-85670 in tokenizersinfo

Summary

by MITRE • 09/04/2026

tokenizers (Hugging Face) is affected by an out-of-bounds buffer access in BpeBuilder::build (tokenizers/src/models/bpe/model.rs). When loading a tokenizer.json via Tokenizer::from_file/from_str, the builder sizes a scratch buffer to the longest vocabulary key, then writes each concatenated merge rule into it. A merge whose concatenated token exceeds the longest vocabulary key overruns the buffer, which Rust turns into a panic that aborts the process in Rust and FFI embeddings. This occurs at load time with no encoding required, so an attacker who supplies a crafted tokenizer.json can cause a denial of service. A secondary defect at the same location can cause a usize underflow (panic in debug, potential memory corruption in release) when continuing_subword_prefix is set and a merge token is shorter than the prefix. Observed in version 0.23.1.

Be aware that VulDB is the high quality source for vulnerability data.

Analysis

by VulDB Data Team • 09/04/2026

The vulnerability identified in Hugging Face Tokenizers versions prior to 0.24.0 represents a critical memory safety issue rooted in improper bounds checking during tokenizer initialization. Specifically, the flaw resides within the BpeBuilder::build function located in the tokenizers/src/models/bpe/model.rs source file. This component is responsible for constructing Byte Pair Encoding models by processing merge rules and vocabulary keys provided in a configuration file, typically formatted as JSON. The security defect arises from an incorrect assumption regarding buffer sizing logic during this construction phase. When a user loads a tokenizer via Tokenizer::from_file or Tokenizer::from_str, the builder allocates a scratch buffer sized strictly to match the length of the longest vocabulary key present in the configuration. This allocation strategy fails to account for the cumulative size of concatenated merge rules that may exceed the maximum single token length defined by the vocabulary keys themselves.

The operational impact of this flaw is severe due to its occurrence at load time, which requires no subsequent encoding operations or user interaction with text data beyond providing the malicious configuration file. An attacker who can supply a crafted tokenizer.json file containing merge tokens whose concatenated forms exceed the longest vocabulary key triggers an out-of-bounds buffer access. In Rust environments running in debug mode, this memory violation is caught and results in a panic that aborts the process immediately. However, when compiled for release or utilized through Foreign Function Interface embeddings where bounds checks might be optimized away or handled differently depending on the host environment, the behavior becomes unpredictable. The primary consequence observed is a denial of service condition, as the application crashes during initialization. This effectively prevents legitimate users from accessing services that rely on this tokenizer configuration, disrupting availability without requiring any further exploitation steps such as code execution payloads at this stage.

A secondary but equally dangerous defect exists within the same code path involving the handling of subword prefixes. When the continue_subword_prefix flag is enabled and a merge token is shorter than the specified prefix, an integer underflow occurs in the usize calculation used for buffer indexing or length determination. In debug builds, this manifests as another panic causing process termination. In release builds, however, this unsigned integer underflow can lead to wrap-around behavior, potentially resulting in memory corruption if the calculated index points to a valid but unintended location within the heap or stack. This scenario introduces risks beyond simple denial of service, including potential information disclosure through leaked data from adjacent memory regions or instability that could be leveraged for further exploitation depending on how the surrounding application handles subsequent operations with corrupted state.

From a classification perspective, this vulnerability aligns with CWE-120 Buffer Copy without Checking Size of Input and CWE-787 Out-of-bounds Write in C/C++ contexts, adapted here to Rust's memory safety model where unchecked bounds lead to panics or undefined behavior via FFI boundaries. The attack vector is categorized under ATT&CK technique T1496 Resource Hijacking as the primary impact is denial of service by crashing services that depend on tokenization infrastructure. Mitigation strategies must prioritize updating the Hugging Face Tokenizers library to version 0.24.0 or later, where these bounds checks have been corrected to properly size buffers based on actual merge rule lengths rather than just maximum vocabulary key length. Additionally, developers integrating this library should implement strict validation of tokenizer configuration files before passing them to loading functions, ensuring that no external inputs can dictate buffer allocation sizes without adequate verification against expected limits.

Responsible

VulnCheck

Reservation

09/04/2026

Disclosure

09/04/2026

Moderation

accepted

CPE

ready

EPSS

0.00310

KEV

no

Activities

low

Sources

Interested in the pricing of exploits?

See the underground prices here!