Smarty: Code injection via nocache hash forgery in extends inheritance
Summary
Smarty, a PHP template engine, does not restore the top-level nocache hash when templates use extends: or multi-component inheritance. An attacker who can supply assigned template data containing a forged nocache marker can get arbitrary PHP code written into the regenerated cache file, which is executed on the next include. The vulnerability requires caching, inheritance and request-controlled values echoed unescaped, and the default output is unescaped.
Affected
- Smarty before 4.5.8
- Smarty 5.x before 5.8.5
- Smarty 3.x: unknown, no vendor statement; scanners flag 3.1.39 and the CVE record range starts at 0, so treat it as potentially affected
Fixed in
- Smarty 4.5.8
- Smarty 5.8.5
- Linux distribution packages: unknown, check the status of your distribution
Workaround
Unknown. No vendor workaround is documented; patching is the only confirmed fix.
Exploitation
- Public proof of concept: yes, available on GitHub and exploit aggregators
- Exploited in the wild: no evidence found; not verified against the CISA KEV catalogue
- CISA SSVC: exploitation poc, automatable no, technical impact total
Our recommendation
- Inventory PHP applications that use Smarty, including bundled copies in shop, CMS or web-app software
- Update Smarty to 4.5.8 or 5.8.5, or ask your software provider for the patched version
- After patching, clear the compile and cache directories and check cache files for unexpected PHP code
- Restrict write access to the Smarty compile and cache directories
- Escalate immediately if an affected system is internet-facing
Public exploits
Links to third-party sites, not checked by us – exploit code can contain malware. Only use it in isolated test environments.
- Proof of concept on GitHub (1 repositories)
murrez/CVE-2026-82531
Research sources
- Fix commit 1cba51c github.com
- Fix commit c0fdd48 github.com
- Smarty release 4.5.8 github.com
- Smarty release 5.8.5 github.com
- GitHub Security Advisory GHSA-3w63-v7pm-cq9x github.com
- VulnCheck advisory www.vulncheck.com
- Public PoC on GitHub github.com
- Ubuntu security tracker ubuntu.com
Researched and written up in English and German by an AI (Claude by Anthropic) based on NVD, CISA, EPSS and the sources listed. The vendor information is authoritative. Researched on 31 Oct 2026, 04:52.
Original description (NVD)
Smarty before 4.5.8 and 5.x before 5.8.5 contains a code injection vulnerability where the top-level nocache_hash is never restored during extends:/multi-component template inheritance, leaving it null. Attackers can supply assigned data containing a forged SmartyNocache marker that is copied verbatim into the regenerated PHP cache file, executing arbitrary PHP on include for remote code execution.
NVD references (7)
- https://github.com/smarty-php/smarty/commit/1cba51cb813563eb61d963c83d28cd59f26b858d
- https://github.com/smarty-php/smarty/commit/c0fdd4824aca4f67e814b50703cfee1dfde41414
- https://github.com/smarty-php/smarty/releases/tag/v4.5.8
- https://github.com/smarty-php/smarty/releases/tag/v5.8.5
- https://github.com/smarty-php/smarty/security/advisories/GHSA-3w63-v7pm-cq9x
- https://www.vulncheck.com/advisories/smarty-before-4.5.8-and-5-x-before-5.8.5-php-code-injection-via-extends-…
- https://github.com/smarty-php/smarty/security/advisories/GHSA-3w63-v7pm-cq9x
Sources
The tracker combines official, freely usable data sources – updated continuously:
- NVD (NIST) – CVEs, rating (CVSS), affected products
- CISA KEV – vulnerabilities confirmed by CISA as actively exploited
- CISA Vulnrichment – CISA assessment (SSVC) in the official CVE record
- FIRST EPSS – probability of exploitation
- Microsoft MSRC – Patch Tuesday: vulnerabilities, severity, updates
- PoC-in-GitHub – public proof-of-concept repositories
- Metasploit (Rapid7) – modules of the Metasploit Framework
- Exploit-DB (OffSec) – archive of public exploits (links only)
- Patch days: official vendor pages (linked per vendor) (Vendor patch days)
This product uses data from the NVD API but is not endorsed or certified by the NVD. EPSS data © FIRST.org.
Affected? We can help.
We check whether your systems are affected, install updates and close the gap – continuously with the System Health Checker if you wish.
