Modelwire
Subscribe

Structural Role Injection in Handlebars-Templated LLM Prompts: Triple-Brace Interpolation, Delimiter Family, and the Limits of HTML Auto-Escaping

Illustration accompanying: Structural Role Injection in Handlebars-Templated LLM Prompts: Triple-Brace Interpolation, Delimiter Family, and the Limits of HTML Auto-Escaping

Researchers have identified a critical vulnerability in how large language model applications handle templated prompts, specifically within Handlebars templating used by Microsoft Semantic Kernel. The work reveals that HTML auto-escaping, marketed as the safe default for interpolating user data, fails to neutralize role-delimiter injection attacks across multiple LLM chat protocols. While escaping blocks ChatML, Llama-3, and XML delimiters, it leaves Llama-2's bracket-based syntax exposed, allowing attackers to forge higher-privilege conversation turns. This finding exposes a gap between documented security assumptions and actual attack surface in production prompt-engineering frameworks, affecting any application relying on Handlebars for dynamic prompt construction.

Modelwire context

Explainer

The core finding isn't just that a vulnerability exists, it's that the security guarantee being sold to developers (HTML auto-escaping as the safe default) is selectively true, covering some chat protocols while leaving others exposed depending on which LLM backend the application happens to use. The attack surface is therefore invisible at the framework layer and only visible when you know which model is downstream.

This connects directly to the red-team study of Anthropic's Fable 5 and Opus 4.8 models covered here recently, which found that static defenses hold against most attacks but dynamic adversarial search remains a credible threat. That paper focused on model-level robustness; this one reveals that the scaffolding around models, specifically the templating layer, introduces its own attack surface before adversarial prompts even reach the model. Together they suggest that security assessments scoped only to model behavior will systematically miss infrastructure-level injection paths.

Watch whether Microsoft Semantic Kernel ships an explicit patch or deprecation notice for triple-brace interpolation in Handlebars templates within the next 60 days. If they do not, it signals that framework maintainers are treating this as a developer-responsibility issue rather than a library-level fix, which would leave the majority of production deployments exposed by default.

This analysis is generated by Modelwire’s editorial layer from our archive and the summary above. It is not a substitute for the original reporting. How we write it.

MentionsMicrosoft Semantic Kernel · Handlebars · ChatML · Llama-3 · Llama-2 · XML

MW

Modelwire Editorial

This synthesis and analysis was prepared by the Modelwire editorial team. We use advanced language models to read, ground, and connect the day’s most significant AI developments, providing original strategic context that helps practitioners and leaders stay ahead of the frontier.

Modelwire summarizes, we don’t republish. The full content lives on arxiv.org. If you’re a publisher and want a different summarization policy for your work, see our takedown page.

Structural Role Injection in Handlebars-Templated LLM Prompts: Triple-Brace Interpolation, Delimiter Family, and the Limits of HTML Auto-Escaping · Modelwire