PHP Code Injection by malicious block or filename in Smarty
Key facts
- Attack vector
- Network
- Privileges required
- Low
- User interaction
- None
- Attack complexity
- Low
- Impact type
- Code execution
- Confidentiality · integrity · availability
- High · High · High
- Fix status
- Fixed
Attack profile from CVSS 3.1 · CNA. Fix status from CNA and GitHub. Impact type from CWE-94.
Summary
Smarty is a template engine for PHP, facilitating the separation of presentation (HTML/CSS) from application logic. Prior to versions 3.1.45 and 4.1.1, template authors could inject php code by choosing a malicious {block} name or {include} file name. Sites that cannot fully trust template authors should upgrade to versions 3.1.45 or 4.1.1 to receive a patch for this issue. There are currently no known workarounds.
Why it matters now
SSVC decision points
CISA ADP · SSVC 2.0.3
- Exploitation
- None
- Automatable
- No
- Technical impact
- Total
The decision (Track, Attend, Act) also depends on your mission and well-being impact; see CISA's SSVC guide.
Affected products
| Vendor | Product | Affected versions | Fixed in | Status | Source |
|---|---|---|---|---|---|
| smarty-php | smarty | before 3.1.45; 4.0.0 to before 4.1.1 | 3.1.45, 4.1.1 | Patch available | CNA |
| — | smarty/smarty (Packagist) | before 3.1.45 | 3.1.45 | Patch available | GHSA-634x-pc3q-cf4c |
| — | smarty/smarty (Packagist) | 4.0.0 to before 4.1.1 | 4.1.1 | Patch available | GHSA-634x-pc3q-cf4c |
- smarty Vendorsmarty-php Affected before 3.1.45; 4.0.0 to before 4.1.1 Fixed in 3.1.45, 4.1.1 Patch available CNA
- smarty/smarty (Packagist) Vendor— Affected before 3.1.45 Fixed in 3.1.45 Patch available GHSA-634x-pc3q-cf4c
- smarty/smarty (Packagist) Vendor— Affected 4.0.0 to before 4.1.1 Fixed in 4.1.1 Patch available GHSA-634x-pc3q-cf4c
CPE configurations NVD · 6
| CPE | Versions | Role | Vendor |
|---|---|---|---|
| cpe:2.3:a:smarty:smarty:*:*:*:*:*:*:*:* | before 3.1.45; 4.0.0 to before 4.1.1 | Vulnerable | smarty-php |
| cpe:2.3:o:debian:debian_linux:9.0:*:*:*:*:*:*:* | 9.0 | Vulnerable | Debian |
| cpe:2.3:o:debian:debian_linux:10.0:*:*:*:*:*:*:* | 10.0 | Vulnerable | Debian |
| cpe:2.3:o:debian:debian_linux:11.0:*:*:*:*:*:*:* | 11.0 | Vulnerable | Debian |
| cpe:2.3:o:fedoraproject:fedora:36:*:*:*:*:*:*:* | 36 | Vulnerable | Fedoraproject |
| cpe:2.3:o:fedoraproject:fedora:37:*:*:*:*:*:*:* | 37 | Vulnerable | Fedoraproject |
- cpe:2.3:a:smarty:smarty:*:*:*:*:*:*:*:* Versions before 3.1.45; 4.0.0 to before 4.1.1 Vulnerable ·smarty-php
- cpe:2.3:o:debian:debian_linux:9.0:*:*:*:*:*:*:* Versions 9.0 Vulnerable ·Debian
- cpe:2.3:o:debian:debian_linux:10.0:*:*:*:*:*:*:* Versions 10.0 Vulnerable ·Debian
- cpe:2.3:o:debian:debian_linux:11.0:*:*:*:*:*:*:* Versions 11.0 Vulnerable ·Debian
- cpe:2.3:o:fedoraproject:fedora:36:*:*:*:*:*:*:* Versions 36 Vulnerable ·Fedoraproject
- cpe:2.3:o:fedoraproject:fedora:37:*:*:*:*:*:*:* Versions 37 Vulnerable ·Fedoraproject
Remediation
- Fix · CNA smarty (smarty-php) Fixed in 3.1.45, 4.1.1
- Fix · GHSA-634x-pc3q-cf4c smarty/smarty (Packagist) Fixed in 3.1.45 Advisory →
- Fix · GHSA-634x-pc3q-cf4c smarty/smarty (Packagist) Fixed in 4.1.1 Advisory →
Vendor assessments
Timeline
- 2026-10-02 Threatist record created from CVE-2022-29221
- 2026-10-03 Alias added: GHSA-634x-pc3q-cf4c
References
Advisory 9
- https://github.com/smarty-php/smarty/security/advisories/GHSA-634x-pc3q-cf4c
- https://github.com/smarty-php/smarty/releases/tag/v3.1.45
- https://github.com/smarty-php/smarty/releases/tag/v4.1.1
- [debian-lts-announce] 20220529 [SECURITY] [DLA 3033-1] smarty3 security update
- DSA-5151
- GLSA-202209-09
- FEDORA-2022-52154efd61
- FEDORA-2022-d5fc9dcdd7
- https://nvd.nist.gov/vuln/detail/CVE-2022-29221
Other 4
- https://github.com/FriendsOfPHP/security-advisories/blob/master/smarty/smarty/CVE-2022-29221.yaml
- https://github.com/smarty-php/smarty
- https://lists.fedoraproject.org/archives/list/[email protected]/message/BRAJVDRGCIY5UZ2PQHKDTT7RMKG6WJQQ
- https://lists.fedoraproject.org/archives/list/[email protected]/message/L777JIBIWJV34HS7LXPIDWASG7TT4LNI
More smarty-php Smarty vulnerabilities
- TI-2021-08070 Smarty before 3.1.39 allows code injection via an unexpected function name after a {function name= substring. CVSS 3.1CRITICAL 9.8
- TI-2009-01585 The smarty_function_math function in libs/plugins/function.math.php in Smarty 2.6.22… CVSS 2.0HIGH 10.0
- TI-2006-06846 PHP remote file inclusion vulnerability in libs/Smarty.class.php in Smarty 2.6.9 allows… CVSS 3.1CRITICAL 9.8
- TI-2017-14689 Smarty 3 before 3.1.32 is vulnerable to a PHP code injection when calling fetch() or… CVSS 3.0CRITICAL 9.8
- TI-2010-04450 Smarty before 3.0.0 beta 7 does not properly handle the <?php and ?> tags, which has… CVSS 2.0HIGH 10.0
- TI-2010-04449 Unspecified vulnerability in the math plugin in Smarty before 3.0.0 RC1 has unknown… CVSS 2.0HIGH 10.0
Sources
- CVE-2022-29221 · CVE Program
- CVE-2022-29221 · NVD
- FIRST EPSS
- GHSA-634x-pc3q-cf4c · GitHub Advisory Database · CC BY 4.0
- CVE-2022-29221 · Red Hat security data · CC BY 4.0
This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences