Skip to main content

Smarty CVE-2026-82531

| EUVDEUVD-2026-93376 CRITICAL
Code Injection (CWE-94)
2026-10-06 VulnCheck
9.2
CVSS 4.0 · Vendor: VulnCheck
View

Attack ChainAIDerived

Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain

  1. Recon
    Submit input containing forged SmartyNocache marker
  2. Delivery
    Benign render compiles inheritance template and caches output
  3. Exploit
    Cache evicted via TTL expiry while compiled file persists
  4. Install
    Fresh PHP process reloads compiled file with null nocache_hash
  5. C2
    Empty regex alternative accepts forged marker, payload written verbatim to cache
  6. Execute
    Cache file include() executes attacker PHP as application
  7. Impact
    Remote code execution on server

Vulnerability Assessment

Weakness
CWE
OWASP Top 10:2025
A05:2025 - Injection
ASVS 5.0
V1 - Encoding and Sanitization Code injection prevention, sandbox exec
MITRE ATT&CK

2 techniques across 2 tactics: Execution, Initial Access

The technique list with ATT&CK links and the kill-chain view is part of the Basic plan and up.

Exploitation Conditions

Requires all of: (1) templates rendered via the extends:/multi-component inheritance path (not single-file templates); (2) caching enabled (e.g. CACHING_LIFETIME_CURRENT); (3) attacker-controlled assigned data emitted unescaped into template output; and (4) a fresh PHP process that reloads the compiled file from disk after the cache entry is evicted (TTL expiry or cache clear) while compiled files remain - this is the state in which the top-level unifunc's nocache_hash is null. Limiting factors: if the application does not use template inheritance, does not enable caching, or escapes/validates the attacker-supplied value, exploitation does not occur; the dependency on a post-eviction fresh-process reload (reflected as AT:P in CVSS 4.0) means exploitation is conditional rather than reliably on-demand. No special user interaction or authentication is required by the flaw itself.

Impact

This is a genuine high-priority vulnerability, but one whose real-world exploitability is gated by several preconditions that the raw 9.2 CVSS score obscures. The CVSS 4.0 vector (AV:N/AC:L/AT:P/PR:N/UI:N) describes a network-reachable, unauthenticated flaw with HIGH impact across confidentiality, integrity and availability (VC:H/VI:H/VA:H) - consistent with CWE-94 code injection yielding PHP RCE. The critical nuance is AT:P (Attack Requirements: Present), which signals that exploitation is NOT unconditional: per the vendor advisory and the regression test, the target must render templates through the extends:/multi-component inheritance path, have caching enabled, pass attacker-controlled data into an unescaped output, and crucially a fresh PHP process must reload the compiled file from disk (after cache eviction/TTL expiry) so that nocache_hash is left null. There is NO CISA KEV listing and no EPSS score provided, and no public weaponized exploit is indicated in the input; the only exploitation artifact is the vendor's own defensive regression test shipped with the fix, which demonstrates the mechanism but is not a drop-in attack tool. Signals therefore align rather than conflict: high technical impact is real, but neither active exploitation nor mass-scanning pressure is evidenced yet, so this reads as a serious, patch-now issue for exposed PHP/Smarty deployments rather than a confirmed in-the-wild emergency. Verify your environment actually uses template inheritance with caching before deprioritizing or over-prioritizing.

Exploit ScenarioDerived

An attacker submits a value (e.g. a form field or profile name) that is assigned into a Smarty template and echoed unescaped; the value embeds a forged '/*%%SmartyNocache:%%*/ ... /*/%%SmartyNocache:%%*/' marker wrapping raw PHP. On a Smarty instance using extends:/inheritance with caching, after the cache entry expires and a fresh PHP process regenerates it, the null top-level nocache_hash produces an empty regex alternative that treats the forged marker as a real nocache section, copying the attacker's PHP verbatim into the cache file. That PHP then executes on the next include(), yielding remote code execution. No public exploit is identified in the input, though the vendor shipped a regression test demonstrating the mechanism.

Act Now Prioritize within 24-48h. Why: CRITICAL severity.
Patch available 0.8% exploitation probability (EPSS)

Get an e-mail when this CVE is exploited, patched or re-scored. Free account.

Alert me

AnalysisAIv1 – Oct 06, 2026

PHP code injection in the Smarty templating engine allows remote code execution in applications running Smarty 4.x before 4.5.8 or 5.x before 5.8.5 that render templates through the extends:/multi-component inheritance path with caching enabled. When such a template is compiled, the top-level unifunc never restores its nocache_hash, so the value is null; combined with an empty regex alternative in the cache-split logic, attacker-controlled assigned data containing a forged /*%%SmartyNocache:%%*/ marker is copied verbatim (bypassing PHP-tag neutralization) into the regenerated PHP cache file and executed on the next include. Exploitation is unauthenticated per the vendor CVSS vector (PR:N) but is gated by strict preconditions - inheritance-path templates, active caching, unescaped attacker-controlled output, and a fresh PHP process that reloads the compiled file after the cache entry is evicted (TTL expiry or cache clear) while compiled files persist - making it conditional rather than reliably on-demand; no public exploit code or confirmed in-the-wild exploitation was identified at time of analysis.

RemediationAI

Vendor-released patch: upgrade to Smarty 4.5.8 or Smarty 5.8.5 (or later). The fixes are the upstream commits c0fdd4824aca4f67e814b50703cfee1dfde41414 and 1cba51cb813563eb61d963c83d28cd59f26b858d, and the tagged releases are available at https://github.com/smarty-php/smarty/releases/tag/v4.5.8 and https://github.com/smarty-php/smarty/releases/tag/v5.8.5, with the advisory at https://github.com/smarty-php/smarty/security/advisories/GHSA-3w63-v7pm-cq9x. If an immediate upgrade is not possible, compensating controls should target the specific preconditions: (1) disable Smarty caching (set caching to CACHING_OFF or clear the cache directory and disable cache writing) - this removes the cache-regeneration step entirely but costs performance on every request; (2) avoid the extends:/multi-component template inheritance path in favor of single-file templates until patched - effective but may require template restructuring; (3) ensure all values passed to templates from untrusted sources are escaped or validated before assignment, ideally by enabling Smarty's default HTML escaping and avoiding |unescape / nofilter modifiers on user-controlled data - this blocks the injection vector but must be applied consistently, since a single unescaped sink is sufficient; and (4) never serve cache or compile directories over the web and restrict filesystem write access to them, which limits how injected content can be reached. Because exploitation requires a fresh PHP process reloading a compiled file after cache eviction, aggressively clearing both compiled and cached artifacts on deploy reduces exposure, though it is not a substitute for patching. Note the flaw is unauthenticated per the provided CVSS vector (PR:N), so network exposure to any vulnerable template path should be treated as high priority even though exploitation is conditional.

Affected VersionsENISA

smarty 0 <4.5.8
smarty 5.0.0 <5.8.5

Affected Packages

euvd smarty fix: 4.5.8, 5.8.5

Source: OSV (Open Source Vulnerabilities)

Affects your stack

Affects 1 package in euvd

Checking this CVE against your own stacks and servers is part of the Basic plan and up.

Technical ContextAI · show details

Smarty is a widely deployed PHP template engine that compiles templates into PHP files under a compile directory and, when caching is enabled, writes rendered output into cache files. The root cause is CWE-94 (Improper Control of Generation of Code / Code Injection) in \Smarty\Template\Cached::removeNoCacheHash(). Normally, nocache sections are delimited by /*%%SmartyNocache:<hash>%%*/ ... /*/%%SmartyNocache:<hash>%%*/ markers, and the hash is gathered from the compiled template's nocache_hash to build a regex alternation used to split cached from non-cached content. A template compiled through the inheritance/component path ('extends:') produces a top-level unifunc that never restores its nocache_hash, leaving it null on a fresh process that reloads the compiled file from disk. Folding that null into the alternation yields an empty alternative such as '(realhash|)', which matches a forged marker with no hash. Because content matched as a genuine nocache section is reproduced verbatim into the cache file without PHP-tag neutralization, an attacker who controls an assigned value echoed unescaped into the template can inject raw PHP that is written into the regenerated cache and executed when the cache file is subsequently include()d. The upstream fix guards the null case (only folding in a non-empty nocache hash, filtering empty hashes) and, when no legitimate nocache hashes exist, treats the entire buffer as ordinary output so PHP tags are neutralized; a regression test (NocacheHashInjectionTest) verifies the forged marker is not executed.

Know when Smarty gets its next vulnerability

  • Watch products and get an email when something new is published
  • Check this CVE against your own stack and servers
  • Exploit and PoC references, threat intelligence from 22 sources

No credit card · 7-day full trial

Severity by source

Vendor (VulnCheck) PRIMARY 9.2 CRITICAL
CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N
vuln.today AI 8.1 HIGH

Network-reachable and unauthenticated (AV:N/PR:N), but the required inheritance+caching path, cache eviction and fresh-process reload make it AC:H; successful PHP RCE gives full C:H/I:H/A:H with no scope change.

3.1 AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H
4.0 AV:N/AC:L/AT:P/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N

Primary rating from Vendor (VulnCheck).

CVSS VectorVendor: VulnCheck

Attack Vector
Network
Attack Complexity
Low
Attack Requirements
Present
Privileges Required
None
User Interaction
None
Vulnerable system: Confidentiality
High
Vulnerable system: Integrity
High
Vulnerable system: Availability
High
Subsequent system: Confidentiality
None
Subsequent system: Integrity
None
Subsequent system: Availability
None

DescriptionCVE.org

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.

Technical POC Analysis

CWE-94 code injection in Smarty's cache generation.

Full technical POC analysis - root cause, step-by-step exploitation and patch breakdown - is part of the Pro and Business plans.

Executive ViewAI

Why It Matters

A critical remote code execution vulnerability in the Smarty templating engine (4.x before 4.5.8 and 5.x before 5.8.5) could let an unauthenticated attacker run arbitrary code on applications that render inherited templates with caching enabled. Because Smarty ships inside a broad range of PHP-based web applications and customer-facing platforms, a successful exploit could mean full server compromise, exposure of customer and business data, and service disruption. Exploitation depends on a specific combination of template design, caching configuration and unescaped user input, so risk is concentrated in internet-facing applications that meet those preconditions and should be prioritized for remediation.

Business Impact: High
Compensating Controls

Apply vendor patch.

Threat Intelligence Overview

EPSS Score
0.8%
Top 44% exploitable
Prevalence
High
Smarty is a widely deployed PHP templating engine across legacy and current web apps
Social Media
3
Sightings
Data Quality
5 sources
Confidence: Medium

How this decision was reached

The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.

SignalValue
Severity CRITICAL
CISA KEV No
Public POC No
EPSS 0.8%
Patch available Yes
Active threat No
Deciding rule
CRITICAL severity
What every action level means
Emergency Immediate action required. Criteria: CRITICAL + in CISA KEV (actively exploited) without patch, OR CRITICAL + EPSS > 30% without patch, OR CRITICAL + active threat signals without patch.
Act Now Prioritize within 24-48h. Criteria: in KEV with patch available, OR CRITICAL + public POC, OR HIGH + EPSS > 10%, OR CRITICAL + active threat, OR any CRITICAL severity.
This Week Schedule remediation this week. Criteria: HIGH severity (CVSS 7.0-8.9). Patch within normal change window.
This Month Plan within 30 days. Criteria: MEDIUM severity (CVSS 4.0-6.9), lower exploitation probability. Include in regular patch cycle.
Monitor Track and reassess. Criteria: LOW severity (CVSS 0.1-3.9), minimal exploitation risk. No immediate action needed.

SSVC AssessmentENISA

SSVC Decision
Scheduled
Exploitation
Poc
System Exposure· derived
Open
Automatable
No
Human Impact
High
Technical Impact
Total

Priority Score

47
Low Medium High Critical
KEV: 0
EPSS: +1
CVSS: +46
PoC: 0
Weaponized: 0
Threat intel: 0
Gov advisory: 0

Attack Technique

Code Injection CRITICAL

Code injection occurs when an application accepts user input and passes it directly into a language interpreter or evaluator without proper sanitization.

Remote Code Execution represents the critical moment when an attacker successfully runs arbitrary code on a target system without physical access.

More in Smarty

View all
CVE-2014-8350 HIGH POC
7.5 Nov 03

Smarty before 3.1.21 allows remote attackers to bypass the secure mode restrictions and execute arbitrary PHP code as de

CVE-2018-13982 HIGH POC
7.5 Sep 18

Smarty_Security::isTrustedResourceDir() in Smarty before 3.1.33 is prone to a path traversal vulnerability due to insuff

CVE-2026-62996 MEDIUM POC
6.9 Aug 07

Smarty PHP template engine versions 5.0.0 through 5.8.3 expose a security policy bypass allowing file disclosure via the

CVE-2018-16831 MEDIUM POC
5.9 Sep 11

Smarty before 3.1.33-dev-4 allows attackers to bypass the trusted_dir protection mechanism via a file:./../ substring in

CVE-2021-26120 CRITICAL
9.8 Feb 22

Smarty before 3.1.39 allows code injection via an unexpected function name after a {function name= substring. Rated crit

CVE-2022-29221 HIGH
8.8 May 24

Smarty is a template engine for PHP, facilitating the separation of presentation (HTML/CSS) from application logic. Rate

CVE-2012-4277 MEDIUM POC
4.3 Aug 13

Cross-site scripting (XSS) vulnerability in the smarty_function_html_options_optoutput function in distribution/libs/plu

CVE-2021-26119 HIGH
7.5 Feb 22

Smarty before 3.1.39 allows a Sandbox Escape because $smarty.template_object can be accessed in sandbox mode. Rated high

CVE-2026-62993 MEDIUM
6.9 Aug 31

Server-side request forgery in Smarty's {fetch} template function (versions prior to 4.5.7 on the 4.x line and 5.8.2 on

CVE-2026-62992 MEDIUM
6.9 Aug 07

Symlink-based path traversal in Smarty's Security::_checkDir() allows an attacker who can place a symbolic link inside a

CVE-2023-28447 MEDIUM
6.1 Mar 28

Smarty is a template engine for PHP. Rated medium severity (CVSS 6.1), this vulnerability is remotely exploitable, no au

CVE-2023-41661 MEDIUM
4.8 Sep 29

Auth. Rated medium severity (CVSS 4.8), this vulnerability is remotely exploitable, low attack complexity. No vendor pat

This site uses cookies essential for authentication and security. No tracking or analytics cookies are used. Privacy Policy