---
title: "CWE-1336: Improper Neutralization of Special Elements Used in a Template Engine"
url: https://radicalnotion.ai/cwe/cwe-1336
type: cwe
description: "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."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

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

- **Abstraction:** Base
- **Structure:** Simple
- **Status:** Incomplete
- **CVEs with this as primary weakness:** 254
- **Of those, in CISA KEV:** 3
- **New in 2026:** 160
- **CWE catalog version:** 4.21

## Description

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.

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.

## Background

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.

## Alternate terms

- **Server-Side Template Injection / SSTI:** This term is used for injection into template engines being used by a server.
- **Client-Side Template Injection / CSTI:** This term is used for injection into template engines being used by a client.

## Modes of introduction

| Phase | Note |
| --- | --- |
| Architecture and Design | The developer might choose a template engine that makes it easier for programmers to write vulnerable code. |
| Implementation | The programmer might not use engine's built-in sandboxes or other capabilities to escape or otherwise prevent template injection from untrusted input. |

## Applicable platforms

**Languages:** Java (Undetermined), PHP (Undetermined), Python (Undetermined), JavaScript (Undetermined), Interpreted (Undetermined)

**Technologies:** AI/ML (Undetermined), Client Server (Undetermined)

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Integrity | Execute Unauthorized Code or Commands | 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. |

## Potential mitigations

### 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.

## Detection methods

### Automated Static Analysis

Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)

Effectiveness: High

## Observed examples

| CVE | Description |
| --- | --- |
| CVE-2024-34359 | Chain: Python bindings for LLM library do not use a sandboxed environment when parsing a template and constructing a prompt, allowing jinja2 Server Side Template Injection and code execution - one variant of a "prompt injection" attack. |
| CVE-2017-16783 | server-side template injection in content management server |
| CVE-2020-9437 | authentication / identity management product has client-side template injection |
| CVE-2020-12790 | Server-Side Template Injection using a Twig template |
| CVE-2021-21244 | devops platform allows SSTI |
| CVE-2020-4027 | bypass of Server-Side Template Injection protection mechanism with macros in Velocity templates |
| CVE-2020-26282 | web browser proxy server allows Java EL expressions from Server-Side Template Injection |
| CVE-2020-1961 | SSTI involving mail templates and JEXL expressions |
| CVE-2019-19999 | product does not use a "safe" setting for a FreeMarker configuration, allowing SSTI |
| CVE-2018-20465 | product allows read of sensitive database username/password variables using server-side template injection |

## Real CVEs with this weakness (sample of 12 of 254)

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2026-75650 | Adobe Commerce \| Improper Neutralization of Special Elements Used in a Template Engine (CWE-1336) | critical | 10.0 | - | Yes | 2026-09-07 |
| CVE-2024-23692 | Rejetto HTTP File Server 2.3m Unauthenticated RCE | critical | 10.0 | - | Yes | 2024-05-31 |
| CVE-2024-4040 | Unauthenticated arbitrary file read and remote code execution in CrushFTP | critical | 9.3 | - | Yes | 2024-04-22 |
| CVE-2026-103849 | Adobe Commerce \| Improper Neutralization of Special Elements Used in a Template Engine (CWE-1336) | critical | 10.0 | - | No | 2026-10-13 |
| CVE-2026-97359 | HFS2 2.4.0 RCE via Multipart Upload Filename Template Injection | critical | 10.0 | - | No | 2026-09-24 |
| CVE-2026-48323 | Adobe Campaign Classic (ACC) \| Improper Neutralization of Special Elements Used in a Template Engine (CWE-1336) | critical | 10.0 | - | No | 2026-08-03 |
| CVE-2026-44181 | Jupyter Enterprise Gateway: Jinja2 Template Server Side Template Injection results in Remote Code Execution | critical | 10.0 | - | No | 2026-07-16 |
| CVE-2026-33897 | Incus vulnerable to arbitrary file read and write through pongo templates | critical | 10.0 | - | No | 2026-03-26 |
| CVE-2025-59340 | jinjava Sandbox Bypass via JavaType-Based Deserialization | critical | 10.0 | - | No | 2025-09-17 |
| CVE-2025-53833 | LaRecipe is vulnerable to Server-Side Template Injection attacks | critical | 10.0 | - | No | 2025-07-14 |
| CVE-2025-47916 | - | critical | 10.0 | - | No | 2025-05-16 |
| CVE-2025-46661 | - | critical | 10.0 | - | No | 2025-04-28 |

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-94](https://radicalnotion.ai/cwe/cwe-94) | Improper Control of Generation of Code |
| Peer | [CWE-917](https://radicalnotion.ai/cwe/cwe-917) | Improper Neutralization of Special Elements used in an Expression Language Statement |

## Frequently asked questions

### What is CWE-1336?

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.

### What CVEs are caused by CWE-1336?

254 recorded CVEs are attributed to CWE-1336, including CVE-2026-75650, CVE-2024-23692 and CVE-2024-4040. 3 are listed in CISA's Known Exploited Vulnerabilities (KEV) catalog.

### How do you prevent CWE-1336?

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.

### How is CWE-1336 detected?

Automated Static Analysis: Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)

### What are the consequences of CWE-1336?

Exploiting CWE-1336 can lead to: Execute Unauthorized Code or Commands.

### Is CWE-1336 actively exploited?

Yes. 3 CWE-1336 vulnerabilities are in CISA's KEV catalog of actively exploited flaws, out of 254 recorded CVEs.

Primary source: [MITRE CWE](https://cwe.mitre.org/data/definitions/1336.html)

---

Source: [RadicalNotion.AI](https://radicalnotion.ai/cwe/cwe-1336). Licensed CC BY-NC 4.0; attribute RadicalNotion.AI and link the source page when you reuse this data.
