Read the docs
TI-2021-10167 Aliases CVE-2021-29454GHSA-29gp-2c3m-3j6m

Sandbox Escape by math function in smarty

Priority MEDIUM 44CWE-74Published · Updated

Key facts

Attack vector
Network
Privileges required
Low
User interaction
None
Attack complexity
Low
Impact type
—
Confidentiality · integrity · availability
High · High · High
Fix status
Fixed

Attack profile from CVSS 3.1 · NVD. Fix status from CNA and GitHub.

Summary

Smarty is a template engine for PHP, facilitating the separation of presentation (HTML/CSS) from application logic. Prior to versions 3.1.42 and 4.0.2, template authors could run arbitrary PHP code by crafting a malicious math string. If a math string was passed through as user provided data to the math function, external users could run arbitrary PHP code by crafting a malicious math string. Users should upgrade to version 3.1.42 or 4.0.2 to receive a patch.

Why it matters now

Exploitation None reported CISA SSVC · not in CISA KEV
EPSS 0.01861 79th percentileScored 2026-11-07
Fix Fixed smarty (smarty-php): 3.1.42, 4.0.2smarty/smarty (Packagist): 3.1.42, 4.0.2

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

VendorProductAffected versionsFixed inStatusSource
smarty-phpsmartybefore 3.1.42; 4.0.0 to before 4.0.23.1.42, 4.0.2Patch availableCNA
—smarty/smarty (Packagist)before 3.1.423.1.42Patch availableGHSA-29gp-2c3m-3j6m
—smarty/smarty (Packagist)4.0.0 to before 4.0.24.0.2Patch availableGHSA-29gp-2c3m-3j6m
  • smarty Vendorsmarty-php Affected before 3.1.42; 4.0.0 to before 4.0.2 Fixed in 3.1.42, 4.0.2 Patch available CNA
  • smarty/smarty (Packagist) Vendor— Affected before 3.1.42 Fixed in 3.1.42 Patch available GHSA-29gp-2c3m-3j6m
  • smarty/smarty (Packagist) Vendor— Affected 4.0.0 to before 4.0.2 Fixed in 4.0.2 Patch available GHSA-29gp-2c3m-3j6m

CPE configurations NVD · 6

CPEVersionsRoleVendor
cpe:2.3:a:smarty:smarty:*:*:*:*:*:*:*:*before 3.1.42; 4.0.0 to before 4.0.2Vulnerablesmarty-php
cpe:2.3:o:debian:debian_linux:9.0:*:*:*:*:*:*:*9.0VulnerableDebian
cpe:2.3:o:debian:debian_linux:10.0:*:*:*:*:*:*:*10.0VulnerableDebian
cpe:2.3:o:debian:debian_linux:11.0:*:*:*:*:*:*:*11.0VulnerableDebian
cpe:2.3:o:fedoraproject:fedora:36:*:*:*:*:*:*:*36VulnerableFedoraproject
cpe:2.3:o:fedoraproject:fedora:37:*:*:*:*:*:*:*37VulnerableFedoraproject
  • cpe:2.3:a:smarty:smarty:*:*:*:*:*:*:*:* Versions before 3.1.42; 4.0.0 to before 4.0.2 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.42, 4.0.2
  • Fix · GHSA-29gp-2c3m-3j6m smarty/smarty (Packagist) Fixed in 3.1.42 Advisory →
  • Fix · GHSA-29gp-2c3m-3j6m smarty/smarty (Packagist) Fixed in 4.0.2 Advisory →

Vendor assessments

Red Hat

Red Hat's page for this CVE →

Not affected: 1 product
  • Red Hat

Timeline

  1. 2026-10-02 Threatist record created from CVE-2021-29454
  2. 2026-10-03 Alias added: GHSA-29gp-2c3m-3j6m

References

  • 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-2022-11764 PHP Code Injection by malicious block or filename in Smarty CVSS 3.1HIGH 8.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
See all 30 →

Sources