Skip to content

CWE-1336: Improper Neutralization of Special Elements Used in a Template Engine

Base

The product uses a template engine to insert or process externally-influenced input, but it does not neutralize or incorrectly neutralizes special elements or syntax that can be interpreted as template expressions or other code directives when processed by the engine.

Many web applications use template engines that allow developers to insert externally-influenced values into free text or messages in order to generate a full web page, document, message, etc. Such engines include Twig, Jinja2, Pug, Java Server Pages, FreeMarker, Velocity, ColdFusion, Smarty, and many others - including PHP itself. Some CMS (Content Management Systems) also use templates. Template engines often have their own custom command or expression language. If an attacker can influence input into a template before it is processed, then the attacker can invoke arbitrary expressions, i.e. perform injection attacks. For example, in some template languages, an attacker could inject the expression "{{7*7}}" and determine if the output returns "49" instead. The syntax varies depending on the language. In some cases, XSS-style attacks can work, which can obscure the root cause if the developer does not closely investigate the root cause of the error. Template engines can be used on the server or client, so both "sides" could be affected by injection. The mechanisms of attack or the affected technologies might be different, but the mistake is fundamentally the same.

Consequences

  • Integrity: Execute Unauthorized Code or Commands

How to prevent it

  • Architecture and Design: Choose a template engine that offers a sandbox or restricted mode, or at least limits the power of any available expressions, function calls, or commands.
  • Implementation: Use the template engine's sandbox or restricted mode, if available.

Recent advisories

  • GHSA-27vj-qcqg-25rc — fsspec: Server-Side Template Injection in ReferenceFileSystem leads to Remote Code Execution
  • DRUPAL-CONTRIB-2026-175 — The Webform module allows site builders to create forms, collect submissions, and render submitted values in configurable formats.
  • CVE-2026-75650 — Adobe Commerce | Improper Neutralization of Special Elements Used in a Template Engine (CWE-1336)
  • GHSA-73mf-m39p-wpm9 — Yamcs vulnerable to Remote Code Execution via instance-template argument YAML injection (createInstance)
  • GHSA-6wvf-77m9-58rm — LiteLLM vulnerable to server-side template injection in the /prompts/test endpoint
  • GHSA-x67c-8pwr-m8g3 — SiYuan: Second-order SSTI to arbitrary SQL via attribute-view template column (queryBlocks): malicious imported package executes SQL on victim kernel
  • GHSA-2c4f-86xc-cr74 — Grav: XSS Blueprint Validation Bypass via Twig String Concatenation
  • GHSA-65p8-9433-jpcp — YesWiki: Authenticated (Admin) Server-Side Template Injection to Remote Code Execution via Bazar Semantic Templates
  • GHSA-f74w-488g-8x5r — Craft CMS: Potential authenticated Remote Code Execution via referrer redirect
  • GHSA-4j89-2c4f-44c6 — Gogs has DoS in rendering issue index pattern
  • GHSA-7p36-fq2r-4h7r — Pimcore CMS Twig Sandbox Bypass via SecurityPolicy checkMethodAllowed
  • GHSA-c85c-g9wv-pph2 — Apache Airflow vulnerable to Improper Neutralization of Special Elements Used in a Template Engine
  • GHSA-9fx4-7cmj-47vg — Mautic has Server-Side Template Injection (SSTI) in Theme Templates
  • GHSA-xqmj-j6mv-4862 — LiteLLM: Server-Side Template Injection in /prompts/test endpoint
  • GHSA-jcjw-58rv-c452 — Kirby has Server-Side Template Injection (SSTI) via double template resolution in option rendering

All advisories for CWE-1336

Is this in your code?

MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.

Check your repos with MergeHarbor