← All advisories

CVE-2026-139989highSupply chain2026-11-30

CVE-2026-139989: The languagemodels Python package rendered Hugging Face chat templates in an unsandboxed Jinja2 environment, so a malicious model repo could run commands

languagemodels 1.0.0 contains a template injection in Config.use_hf_model. Someone who controls a Hugging Face model repository can put a crafted chat_template in tokenizer_config.json; because languagemodels renders it with an unsandboxed jinja2 environment, the template can reach the os module and run commands with the victim process's privileges when the user loads that model.

01.

What it is

Hugging Face models ship a Jinja2 chat_template in tokenizer_config.json. Libraries are expected to render it in a sandboxed environment.

languagemodels' Config.use_hf_model loaded the template into a plain jinja2 environment, so template code could reach Python internals and the os module.

Exploitation needs the user to load a model from an attacker-controlled repo. The issue was reported in jncraton/languagemodels issue #43 and fixed in pull request #44; NVD references PyPI release 1.0.1.

02.

How to check

  1. Run pip show languagemodels; 1.0.0 is affected.
  2. Check which Hugging Face repos you pass to use_hf_model and whether you trust their owners.
03.

How to fix

  1. Upgrade languagemodels to the fixed release (NVD references 1.0.1 on PyPI).
  2. Only load models from repositories you trust, and pin model revisions.
pip show languagemodels | grep -i '^version'
pip install -U languagemodels
04.

Sources

More advisories for this tool
The weekly email

One email a week. Only what changed.

Every new security hole in AI coding tools, MCP servers, app builders and the stacks they generate (Next.js, Supabase, Node, PHP), each with how to check your app and the fix. No roundups of things you already read.

Free, one email a week. Read the latest issue first if you like. One-click unsubscribe in every email. We never sell or share addresses.