News · DiggingBeagle record

A malicious model chat template crossed a Jinja boundary through a CPython memory error

RunSybil showed code execution from a crafted chat-template artifact through interpreter behavior inside a supposedly restricted Jinja renderer. The finding is not evidence of container escape or autonomous model misconduct.

Published
Nov 10, 2026

The report

A model's chat template was enough to turn a rendering step into executable Python in a controlled demonstration. RunSybil's November 3 disclosure traced the result to CPython generic-alias machinery inside a Jinja environment used to format messages for an inference server. The canonical technical investigation identifies the trust crossing as artifact text entering an interpreter-backed template sandbox, not a chatbot reading a hostile prompt and deciding to obey it.

From model artifact to interpreter state

The attacker-controlled material was a replacement chat-template file loaded as part of a model configuration. When the service rendered a conversation, crafted operations interacted with GenericAlias substitution bookkeeping and an inconsistent cached type-parameter state. RunSybil's exploit chain used that memory error and interpreter internals to escape Jinja's ImmutableSandboxEnvironment and reach host-language code execution within the affected process context.

The demonstration used a modified Qwen model template in an inference setup; the appearance of a well-known model name does not mean its ordinary distribution was malicious. The critical deployment choice is whether an untrusted model artifact can supply executable template logic to a privileged interpreter.

How far did the exploit reach?

The researchers demonstrated Python code running in the service environment, including a container-context root identity in their setup. They did not demonstrate a break out of the container or its underlying host isolation. The CPython issue was handled as an interpreter bug, while the end-to-end question of model-template sandbox ownership spanned multiple projects. Those remediation scopes should not be collapsed into a claim that all inference providers were exposed.

A meaningful repair combines a corrected interpreter/runtime with isolation of template rendering and a vetted provenance path for model artifacts. Restricting model prompts alone is insufficient, because the defect triggers in the template execution machinery before any model output need be trusted. Read the primary technical disclosure for the controlled exploit and disclosure history.

Research behind this