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

Source: https://junglewise.ai/threats/cve-2026-82531-smarty-before-4-5-8-and-5-x-before-5-8-5-contains-a-code  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2026-10-06. Updated: 2026-10-06  
License: CC BY 4.0 with a link back

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](https://junglewise.ai/threats/technologies/smarty). Vendors: [Smarty](https://junglewise.ai/threats/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

- [https://github.com/smarty-php/smarty/commit/1cba51cb813563eb61d963c83d28cd59f26b858d](https://github.com/smarty-php/smarty/commit/1cba51cb813563eb61d963c83d28cd59f26b858d)
- [https://github.com/smarty-php/smarty/commit/c0fdd4824aca4f67e814b50703cfee1dfde41414](https://github.com/smarty-php/smarty/commit/c0fdd4824aca4f67e814b50703cfee1dfde41414)

## Related threats

- [Smarty SSRF via redirect bypass in {fetch}](https://junglewise.ai/threats/cve-2026-62993-smarty-ssrf-via-redirect-bypass-in-fetch)
- [Smarty Security stream restriction bypass in StreamPlugin](https://junglewise.ai/threats/cve-2026-62996-smarty-security-stream-restriction-bypass-in-streamplugin)
- [Smarty is a template engine for PHP, facilitating the separation of presentation (HTML/CSS) from application logic. Prior to 5.8.2 (and 4.5.](https://junglewise.ai/threats/cve-2026-62992-smarty-symlink-path-traversal-in-security-policy)
