jncraton languagemodels can run attacker code via model templates

High 8.5SE Fix-First Score 47/100CVE-2026-139989SE-AIV-00044Other weaknessModels and ML frameworksPublished 1 Dec 2026

Download as PDF

What this means

An attacker who controls a Hugging Face model can run commands on any machine that loads that model using languagemodels. The commands run with the same permissions as the application, so an attacker could read files, install malware, or steal data.

SecurityElites Manager Brief: the decision in one minute

A popular open-source language model library allows attackers to run code on your servers if they can trick you into loading a model they created. Update to version 1.0.1 immediately if you use Hugging Face models with this library.

SecurityElites Fix-First Score47 of 100
Our own ranking of what to fix first. Real attacks count most, then the chance of attack, then severity.
SecurityElites fix windowWithin 30 days
High severity. This is our suggestion from common practice; your own policy comes first.
Who should own the fixPlatform or infrastructure team that manages Python dependencies and AI model loading.
Likely effortAbout 15 minutes: update the library, restart any services that use it, and test that model loading still works. It may take longer if you have many deployments or need to test models in a staging environment first.

Questions to ask your team or supplier

  • Do we allow users or external systems to specify which Hugging Face models to load, or is the model list hardcoded and controlled by us?
  • Have we reviewed the ownership and maintenance status of all Hugging Face models we load, especially any added in the past few months?
  • Do we have detection in place to alert if our applications execute unexpected subprocesses or access files they should not?

Message you can forward to the owning team

Security notice: jncraton languagemodels can run attacker code via model templates (CVE-2026-139989)

Severity: High (8.5 of 10)
SecurityElites Fix-First Score: 47 of 100
SecurityElites fix window: Within 30 days
Action: upgrade to languagemodels 1.0.1 or later.
What we need from you: confirm whether we run this software, who owns it, and the date it will be fixed.
Full guide: https://securityelites.com/ai-vulnerabilities/cve-2026-139989-jncraton-languagemodels-can-run-attacker-code-via-model-templates/
Source: SecurityElites AI Vulnerabilities Database, record SE-AIV-00044

What is at stake in your AI setup

  • Model files from Hugging Face: attackers could modify cached models or poison new model downloads.
  • Keys for Hugging Face API or other AI provider credentials: if stored accessible to the Python process, they could be stolen.
  • Compute bill: an attacker could run expensive inference or fine-tuning jobs using your account.
  • Tools and systems the application connects to: if this library is used in an AI agent, attackers could use the compromised process to access databases, APIs, or other connected services.

Map where your company uses AI

Who is exposed

  • Teams running languagemodels 1.0.0 that load models from Hugging Face model repositories.
  • Services using Config.use_hf_model to load chat models.
  • Applications that allow users to specify which Hugging Face model to load.
  • Teams that load Hugging Face models without reviewing who maintains them.
  • Teams that load only official models from Hugging Face or use a private model registry are at lower risk.

Upgrades you need

SoftwareAffected versionsMove to
jncraton languagemodels1.0.0 up to, but not including, 1.0.11.0.1 or later

The fixed version here was taken from the vendor's own CVE record, because the national database has not listed it yet.

Am I affected?

Enter the version you run. Nothing you type is stored.

SecurityElites Developer Brief: the technical picture

Is it being attackedWorking attack code is public, so expect attacks to follow
Where the attacker must beAlready on the machine, or able to get a user to open something on it
Account neededNone. No login is needed
Does a person have to do somethingYes, a small ordinary action by a user
How hard it is to doEasy. It works reliably once the attacker can reach it
Risk of: data being readHigh
Risk of: data or settings being changedHigh
Risk of: the service being taken downHigh
Can attackers automate it at scaleNo, according to CISA. Each target needs manual work
How much control an attacker gainsTotal control of the affected software, according to CISA

Read from the official severity rating: CVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:P/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X

Kind of coding mistake

  • CWE-1336: a template can be injected

If you cannot upgrade today

  • Until you can upgrade, do not load Hugging Face models from repositories maintained by external users or from user-supplied model names. Only load models published by Hugging Face or your organization.
  • Run languagemodels in a sandboxed environment with limited file and network permissions (container with restricted capabilities, separate user with no shell access).
  • Monitor for unexpected subprocess execution or file writes triggered by model loading.

Signs it may already have been used against you

  • Logs showing subprocess execution (os.system, os.popen, subprocess calls) immediately after a model load or tokenizer initialization.
  • File access or network connections from the Python process that are not part of normal model loading (unexpected writing to config files, downloads from unusual URLs).
  • Errors in languagemodels or jinja2 template processing that mention os module or contain shell commands.
  • Authentication failures or privilege escalation attempts in system logs on machines that load Hugging Face models.

Log searches to start from

Subprocess execution during or after Hugging Face model loading (adapt process and parent process names to your environment)Splunk

process.name=languagemodels OR process.parent.name=python (process.name=bash OR process.name=sh OR process.name=powershell OR process.type=subprocess) | stats count by host, user, process.command_line

Jinja2 or template processing errors with os module references in Python logs (adapt field names)Elastic

process.name:python* AND (message:*jinja2* OR message:*template*) AND (message:*os* OR message:*system*) | stats count by host, user

Written with AI as a starting point. Review them and change the index and field names to match your own logs before you rely on the result.

SecurityElites Fix Guide: step by step

  1. Find where languagemodels is installedCheck all Python environments and container images in your infrastructure. Look for languagemodels in requirements.txt, setup.py, pyproject.toml, Pipfile, or poetry.lock. Also check pip list or poetry show output on running services.
  2. Check the current versionRun python -m pip show jncraton-languagemodels or python -c "import languagemodels; print(languagemodels.__version__)" on each affected system. Record which machines are running 1.0.0.
  3. Review which models are loadedCheck your code, configuration files, and documentation for any place where Config.use_hf_model is called or where Hugging Face model names are specified. Note whether these are official models, private models, or user-supplied model names.
  4. Update languagemodels to version 1.0.1Use your package manager to upgrade: for pip, run pip install --upgrade jncraton-languagemodels==1.0.1; for poetry, run poetry update jncraton-languagemodels. Update your requirements files to pin version 1.0.1 or later.
  5. Restart affected servicesRestart any application or service that imports languagemodels so it loads the new version. This includes Python servers, background jobs, and scheduled tasks.
  6. Test that model loading worksLoad a test model using Config.use_hf_model in your application to confirm the fix did not break functionality. Verify that your most commonly used models still load correctly.
  7. Review model access controlsIf your application allows users to specify which model to load, add controls: only allow models from a whitelist of trusted repositories, require approval before loading new models, or restrict to official Hugging Face models only.
  8. Check logs for suspicious activity before the fixSearch logs from before you applied the fix for any unusual command execution, file access, or errors from languagemodels. Look for model loads followed by unexpected subprocess calls or file operations.

How to confirm it is fixed: Run a test that loads a Hugging Face model with Config.use_hf_model on a machine running 1.0.1, and confirm that the application completes successfully without executing unexpected subprocesses.

SecurityElites Quick Fixes: copy and paste

Check installed versionfor this issue

python -m pip show jncraton-languagemodels

List all Hugging Face model loads in Python codefor this issue

grep -r "use_hf_model\|from_pretrained" --include="*.py" .

Test in a non-production environment first. General hardening examples use placeholder names and ports; change them to match your setup.

Let your AI coding assistant do the upgrade

Paste this into the coding assistant you already use, inside the project. It checks first and asks before it changes anything.

Instruction for your coding assistant

You are helping me fix a security vulnerability (CVE-2026-139989) in this project.\n\n1. Search the whole repository, including lock files, container files and CI configuration, for these packages and list every place they are pinned or installed:\n   - languagemodels: must be 1.0.1 or later
2. Tell me which version we use now and whether it is affected. Stop and ask me before changing anything.
3. After I agree, raise each one to the safe version, update the lock files, and keep every other dependency as it is.
4. Run the tests and tell me what failed.
5. Give me a short summary of the files you changed that I can put in the pull request.

SecurityElites Incident Drill: could your team handle this?

Four questions to ask in your next team meeting. If any has no clear answer, that is the gap to close.

If we load a Hugging Face model and the tokenizer_config.json contains malicious Jinja2 code, what can happen without the fix?A good answer: The attacker code runs with the same permissions as the Python process, allowing them to read files, run commands, steal credentials, or modify data on that machine.
What is the minimum safe version of jncraton languagemodels?A good answer: Version 1.0.1 and any later version; version 1.0.0 is vulnerable.
Who is at risk if we only load models from the official Hugging Face organization?A good answer: Risk is much lower because official models are vetted by Hugging Face, but we should still apply the fix to all systems as a defense-in-depth measure.
How would you detect if an attacker had already exploited this vulnerability on our system?A good answer: Look for subprocess execution or file operations in logs that occurred during or shortly after a model load, especially unexpected shell commands or network connections.

Run a full timed drill with your team

Ticket for your backlog

Paste into Jira, GitHub Issues or any tracker that reads Markdown.

Ready-made ticket

## jncraton languagemodels can run attacker code via model templates (CVE-2026-139989)

**Severity:** High 8.5  |  **SE Fix-First Score:** 47/100  |  **Fix window:** Within 30 days
**Record:** SE-AIV-00044 https://securityelites.com/ai-vulnerabilities/cve-2026-139989-jncraton-languagemodels-can-run-attacker-code-via-model-templates/

### Why this matters
An attacker who controls a Hugging Face model can run commands on any machine that loads that model using languagemodels. The commands run with the same permissions as the application, so an attacker could read files, install malware, or steal data.

### What to do
1. Find where languagemodels is installed: Check all Python environments and container images in your infrastructure. Look for languagemodels in requirements.txt, setup.py, pyproject.toml, Pipfile, or poetry.lock. Also check pip list or poetry show output on running services.
2. Check the current version: Run python -m pip show jncraton-languagemodels or python -c "import languagemodels; print(languagemodels.__version__)" on each affected system. Record which machines are running 1.0.0.
3. Review which models are loaded: Check your code, configuration files, and documentation for any place where Config.use_hf_model is called or where Hugging Face model names are specified. Note whether these are official models, private models, or user-supplied model names.
4. Update languagemodels to version 1.0.1: Use your package manager to upgrade: for pip, run pip install --upgrade jncraton-languagemodels==1.0.1; for poetry, run poetry update jncraton-languagemodels. Update your requirements files to pin version 1.0.1 or later.
5. Restart affected services: Restart any application or service that imports languagemodels so it loads the new version. This includes Python servers, background jobs, and scheduled tasks.
6. Test that model loading works: Load a test model using Config.use_hf_model in your application to confirm the fix did not break functionality. Verify that your most commonly used models still load correctly.
7. Review model access controls: If your application allows users to specify which model to load, add controls: only allow models from a whitelist of trusted repositories, require approval before loading new models, or restrict to official Hugging Face models only.
8. Check logs for suspicious activity before the fix: Search logs from before you applied the fix for any unusual command execution, file access, or errors from languagemodels. Look for model loads followed by unexpected subprocess calls or file operations.

### Done when
- [ ] languagemodels is at 1.0.1 or later everywhere it is installed
- [ ] Lock files, container images and CI configuration are updated
- [ ] Run a test that loads a Hugging Face model with Config.use_hf_model on a machine running 1.0.1, and confirm that the application completes successfully without executing unexpected subprocesses.
- [ ] Logs were checked for signs of earlier use

SecurityElites Fix Tracker

Record who owns this fix, the date it is due and when it is done, and see everything still open in one list. Free with a SecurityElites account.

Sign in to track this fix

Related vulnerabilities

The same kind of mistake in other AI tools

Change history

  • 30 Nov 2026: Made public
  • 1 Dec 2026: Guide updated

Official record

Languagemodels 1.0.0 contains a template injection vulnerability in Config.use_hf_model that allows remote attackers to execute code by supplying a malicious Hugging Face model chat_template. Attackers who control a model repository can craft a chat_template in tokenizer_config.json that reaches the os module through the unsandboxed jinja2 environment, running commands with the victim process privileges.

Weakness type: CWE-1336

Use this record in your own tools

Get this record as JSON

curl https://securityelites.com/wp-json/se-aivd/v1/vulns/CVE-2026-139989

For scanners and pipelines: OSV format · CycloneDX format · API guide · Email alerts · Fix tracker

The plain-language sections were written with AI from the official record, and the upgrade versions come directly from the official data. Last updated 1 Dec 2026. Read the vendor advisory before changing a production system.