← All posts

Where template injection hides in Adobe Commerce code

APSB26-146 fixed a template-injection flaw rated CVSS 10. What that class of bug means, where it hides in Adobe Commerce code, and the habits that prevent it.

On this page · 4 sections
  1. What template injection is
  2. Where it hides in Adobe Commerce code
  3. Habits that prevent it
  4. Checking your own code

TL;DR

  • Template injection is when data a user controls is treated as template code instead of plain text.
  • In Adobe Commerce (Magento 2) the engines at risk are .phtml templates, the email template engine with {{var}} and {{block}} directives, and CMS content filters.
  • Escaping protects the output, but template injection happens before there’s any output to escape. Never pass user input through a directive filter, and keep the roles that can edit templates tight.

In September 2026 Adobe fixed CVE-2026-75650 (bulletin APSB26-146, CVSS 10), a critical flaw in Adobe Commerce classed as CWE-1336, “improper neutralization of special elements used in a template engine”. It needed no login, and Adobe said it was being exploited. I won’t speculate about the exact bug. The class of problem matters more anyway, because the same mistake can live in custom code too.

What template injection is

A template engine turns a template plus some data into output. Adobe Commerce (Magento 2) uses several: .phtml templates, the email template engine with its {{var}} and {{block}} directives, and CMS content filters. Template injection happens when data a user controls is treated as template code instead of as plain text. Then the attacker isn’t filling in a blank. They’re writing part of the program.

Escaping protects the output. Template injection happens before there’s any output to escape.

Where it hides in Adobe Commerce code

  • Directive processing on user input. Passing customer-supplied text (a name, a review, an address line) through a filter that understands {{...}} directives.
  • Building templates from strings. Concatenating input into a template string, then rendering it.
  • Admin-editable content that renders on the storefront. Fine for trusted admins, dangerous if any lower-privileged path can write to it.

Habits that prevent it

  1. Treat every directive filter as a code interpreter. Only feed it content from trusted authors.
  2. Render user input as data: escape it with $escaper->escapeHtml() in templates, and never run it through filter().
  3. Keep admin roles tight. If an editor role can change email templates or CMS blocks, that role is effectively a developer.
  4. Patch quickly (my runbook). Attackers go after known, already-fixed flaws because so many stores stay unpatched. Six weeks after the SessionReaper fix, on the day the attacks started, Sansec counted 62% of Magento stores still vulnerable.

Checking your own code

Search custom modules for places that pass variables into template filters, and review each one.

grep -rnE --include=*.php -e '->filter\(|setVariables\(|processTemplate\(' app/code | less

A match isn’t a bug. It’s a place to read carefully: where does the input come from, and who can change it?

Written by Vishwas Bhatnagar

Technical Architect. Adobe Commerce, marketplaces and AI-assisted engineering.

More about me →

More