Two critical Jinja2 template-injection flaws turned ordinary AI workflow configuration in RAGFlow into a path to full server compromise — and unlike most CVEs that stay theoretical, these are confirmed under active attack. Here's the complete technical picture.
RAGFlow SSTI is a Server-Side Template Injection vulnerability in which attacker-controlled template syntax is processed by an unsandboxed Jinja2 template engine on the RAGFlow server — turning what looks like ordinary prompt or agent configuration into executable code. RAGFlow is a widely used open-source Retrieval-Augmented Generation engine that connects LLMs to enterprise documents, tools, and external systems.
Two distinct CVEs share this root cause, in two different components:
| CVE | Component | Severity | Affected versions |
|---|---|---|---|
CVE-2026-45312 | Prompt Generator | CVSS 3.1: 9.9 Critical | 0.24.0 and earlier |
CVE-2026-28797 | Agent workflow (StringTransform, Message) | CVSS 4.0: 8.7 High / CVSS 3.1: 8.8 High | 0.24.0 and earlier |
Neither requires administrator access. Both let an ordinary authenticated user reach arbitrary operating-system command execution on the RAGFlow server.
This is no longer a theoretical risk. Both CVE-2026-45312 and CVE-2026-28797 have been added to CISA's Known Exploited Vulnerabilities (KEV) catalog. Microsoft has documented real campaigns against exposed RAGFlow instances using these exact flaws — attackers establishing persistent access and harvesting LLM provider API keys and related metadata. Per the coordinated advisory, telemetry showed consistent objectives across cases: credential collection, durable access mechanisms, and resource monetization, even where the specific execution path differed by product. Federal agencies were directed to patch under Binding Operational Directive 26-04.
That detail changes the calculus for anyone running RAGFlow. A CVSS score alone tells you how bad a flaw could be. A KEV listing tells you it's already being used.
The vulnerable code lives in rag/prompts/generator.py, specifically the citation_prompt() function. RAGFlow constructs an ordinary, unsandboxed jinja2.Environment and renders user-controlled prompt configuration through it. A field that looks like prompt configuration is, to the server, executable template logic.
Per the vendor's own advisory, exploitation needs nothing beyond a normal account: any user can register, create a Canvas workflow with a simple component chain, and trigger the injection — no API keys, sandbox service, or embedding model required. That's the attack chain, end to end: register → build a workflow → submit a crafted citation field → the server evaluates it as a template → arbitrary OS command execution.
The published CVSS vector — AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H — reads as network-reachable, low complexity, low privileges required, no user interaction, and high impact across confidentiality, integrity, and availability, with a changed security scope. In plain terms: a low-privileged account is one workflow away from a potential path to full server compromise.
Same underlying mistake, different surface: RAGFlow's Agent workflow StringTransform and Message components (agent/component/string_transform.py, agent/component/message.py) pass user-supplied content directly to jinja2.Template() with no sandboxing. Any authenticated user able to submit or edit an agent template can craft input that escapes the template context and executes system commands.
What makes this pairing significant rather than redundant is where it sits: this one lives in the agent layer, not just prompt configuration. A modern AI agent doesn't just generate text — it can call tools, transform data, retrieve documents, and take real actions. A template-injection flaw reachable through that layer means the same class of bug now threatens the components actually driving autonomous behavior, not just what the model says.
Both advisories describe exploitation by an ordinary authenticated user — not an administrator. That distinction matters more in AI platforms than in traditional web applications, because modern AI tools routinely give regular users real application-level power: creating agents, configuring prompts, defining workflows, connecting tools. A "low-privilege" account in a RAG platform can often do far more than a low-privilege account in a conventional CRUD app.
The real security question isn't "does this require authentication." It's "what can this authenticated identity actually control?" For a multi-tenant RAG deployment, that's the difference between a contained account compromise and a path to the entire server.
The remediation both advisories point to is Jinja2's own SandboxedEnvironment in place of the standard, unrestricted one. RAGFlow's current generator.py does now import and use it — a real, verifiable sign the vulnerable pattern has been addressed in that specific file.
Two caveats worth taking seriously. First, the original advisories list no specific patched version, and RAGFlow has shipped many releases since (the project's latest, v0.27.2, went out September 10, 2026) — a version-number upgrade alone isn't proof of remediation; verify the actual deployed code and current advisories. Second, sandboxing a template engine is necessary but not sufficient on its own. A resilient posture pairs it with strict input validation, least-privilege workflow permissions, runtime isolation, restricted network egress, secrets kept out of application configuration, and monitoring for anomalous child processes — not a single control carrying the whole defense.
Run a free assessment across prompt injection, agentic tool abuse, and the workflow/template layers this analysis covers — mapped to MITRE ATLAS and OWASP LLM Top 10.
Run Free Assessment →For teams operating RAGFlow, or any platform where users can configure templates, prompts, or agent workflows:
Template()/Environment() construction and every .render() call