Hugging Face Patches RunSybil-Discovered AI Supply Chain Bug

Hugging Face has released a patch for a vulnerability, dubbed Jinja2Shell, that could have enabled attackers to breach AI hosting platforms at many of the world’s largest companies. The patch mitigates the threat from the CPython vulnerability RunSybil discovered this past summer. After following our disclosure practices, we made it public earlier this month.
This mitigation protects users who rely on Hugging Face Transformers, one of the most widely used open-source AI libraries, from arbitrary code execution in maliciously crafted models.
The vulnerability, which is in a core component of nearly all large language models (LLMs), allowed a specially crafted template bundled with a model to exploit a CPython memory-safety flaw and execute code inside an AI model’s server. Hugging Face shipped protections in Transformers 5.22.2, giving downstream users a way to address Jinja2Shell at the library level.
Hugging Face’s patch restricts the Python features untrusted templates can abuse to compromise the machines that they execute on. We recommend using the implementation details of the patch as a reference for similar projects looking to harden their code against CPython memory vulnerabilities.
In a statement to RunSybil, Hugging Face noted, “Users should upgrade to transformers v5.22.2 or later, which includes the fix.”
For users who cannot easily upgrade from older, but still supported, versions of CPython, the patch provides a much-needed resolution. A separate fix for the underlying CPython flaw exists, but it’s only available in later interpreter versions. See the CPython fix and backport history for details.
Why This Flaw Matters for the AI Supply Chain
AI hosting platforms are foundational to deploying AI for real-world use, powering a large number of applications for enterprises worldwide. By exploiting this vulnerability, attackers could gain a foothold inside servers responsible for processing millions of user requests. They also could strike directly at the underlying cloud infrastructure hosting those workloads.
Python sandboxes are ubiquitous in the AI ecosystem, notably in the form of Jinja chat templates, which structure interactions between LLMs and users. Breaking out of the chat template sandbox and executing code represents a supply chain risk because it could let bad actors compromise, on a massive scale, the inference engines, libraries, and models that developers and users rely on.
The AI supply chain increasingly depends on the assumption that untrusted model components can be safely contained by sandboxes running under CPython. Our research shows how quickly that assumption can collapse, and how a single CPython flaw can become an arbitrary code-execution path across major inference platforms.
This isn’t the first time a flaw in CPython has led to a sandbox escape. In earlier research, we used a documented out-of-bounds read in CPython to do exactly that. This time, we used an out-of-bounds read that hadn’t been reported before. Human effort paired with GPT-5.6 Sol enabled us to build the exploit in less than a day. Our findings demonstrate that memory-safety flaws in the CPython ecosystem pose a growing risk as AI models get better at discovering them.
For more details about the vulnerability and a technical explanation of the mechanism we used for exploitation, see our original post.
Subscribe to RunSybil Blog
A weekly newsletter covering stories, techniques, guides and the latest product innovations coming.

