CVE-2026-82531: Smarty code injection in template inheritance via nocache hash

CVE-2026-82531 · Severity: high · CVSS 8.1 · Published 2026-10-06

Smarty is a PHP template engine used to render dynamic web content. A vulnerability in template inheritance allows attackers to inject arbitrary PHP code into cached template files through forged nocache markers in assigned data. When a template uses the extends: path for inheritance, an attacker can poison the cached PHP file to execute code remotely when the template is next loaded.

Technologies: Smarty. Vendors: Smarty.

Quick answers

Is CVE-2026-82531 exploited in the wild?
No. Junglewise Threat Intelligence has no report of CVE-2026-82531 being exploited in the wild.
How severe is CVE-2026-82531?
High severity, with a CVSS score of 8.1, published 6 October 2026.
Which products and versions are affected?
Smarty before 4.5.8 and 5.x before 5.8.5.
Is there a fix for CVE-2026-82531?
Yes: fixed in Smarty 4.5.8, 5.8.5. Until then: <UNKNOWN> Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
How is CVE-2026-82531 attacked?
It is attacked over the network, in a software library.
Am I affected by CVE-2026-82531?
Check whether you run Smarty at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

How to fix

  • Fixed in: Smarty 4.5.8, 5.8.5

<UNKNOWN>

Technical details

The vulnerability is a code injection (CWE-94) in Smarty's template inheritance via extends: path. When a template is rendered through extends:/inheritance, the top-level unifunc's nocache_hash is never restored and remains null, causing the cache-split regex to produce an empty alternative "(realhash|)" in Smarty_Internal_Runtime_UpdateCache. This allows attacker-controlled template output to forge a /*%%SmartyNocache:%%*/ marker that gets copied verbatim into the generated PHP cache file as raw PHP code, executing on next include(). The attack requires template inheritance and assignment of attacker-controlled data.

Affected products

  • Smarty Smarty before 4.5.8 and 5.x before 5.8.5

Timeline

  • 2026-10-06: disclosed
  • 2026-10-04: patched

References

This page as Markdown. Free to reuse under CC BY 4.0 with a link back.