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.
References
- github.com/jncraton/languagemodels/blob/a87509…dels/config.py#L366-L380
- github.com/jncraton/languagemodels/commit/48f4…036a3c8a2a0a13
- github.com/jncraton/languagemodels/issues/43
- github.com/jncraton/languagemodels/pull/44
- pypi.org/project/languagemodels/1.0.1/
- vulncheck.com/advisories/languagemodels-1.0.0-…g-use-hf-model