All vulnerabilities

Servers and applications

GHSA-p927-2m49-9p39

Cached page output can become PHP code in the cache file: unescaped quote in the PHP-tag wrapper, and an unchecked pattern failure

Severity
High 8.1
Published
27 Nov 2026
Last changed
27 Nov 2026
Added to UpHeron
27 Nov 2026
Fixed in
4.6.1, 5.9.1
Weakness
Code injection (CWE-94)Improper output encoding (CWE-116)CWE-252
Attack
Over the network · Only under certain conditions · No login needed · No user action needed
Attacker can
Read data · Change data · Take it down
CVSS vector
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H
Sources
Project advisories (GitHub)

Description

With caching on, Smarty writes the rendered output of a page into a cache file and runs that file with include. To keep PHP-looking tags in the output from running, removeNoCacheHash() wraps every match of a tag pattern in a small PHP statement that echoes the tag from a single-quoted string. Two defects in those lines let text printed on the page end up as PHP code in the cache file:

  • Unescaped quote. The matched tag is put into the single-quoted string as it is. One alternative of the pattern, the legacy script tag with a language attribute naming php, may contain a single quote. A match with a single quote after the word php ends the string early, and what follows the tag in the output is compiled as PHP.
  • Unchecked failure. When the pattern match itself fails (preg_match() returns false at pcre.backtrack_limit), the code reads that as "no tag found" and copies the whole text into the cache file with no wrapping at all.
From smarty-php/smarty's security advisory. Shortened; the full text is there.

Affected software

SoftwareAffected versions
SmartyServers and applications · github:smarty-php/smarty
  • Every version before 4.6.1
  • From 5.0.0 before 5.9.1

About Smarty

Web template system in PHP

From Wikidata, CC0 1.0.
Monthly downloads (Packagist)
1,214,404Packagist, 29 Nov 2026
Total downloads (Packagist)
47,010,492Packagist, 29 Nov 2026
GitHub stars
2,352GitHub, 29 Nov 2026
Forks
704GitHub, 29 Nov 2026
Latest release
v5.9.1GitHub, 29 Nov 2026
Released
27 Nov 2026GitHub
License
GNU Lesser General Public LicenseWikidata
Written in
PHPWikidata
First released
2001Wikidata
First published on GitHub
30 Oct 2014GitHub

References