CVE-2021-21408
Access to restricted PHP code by dynamic static class access in smarty
Smarty is a template engine for PHP, facilitating the separation of presentation (HTML/CSS) from application logic. Prior to versions 3.1.43 and 4.0.3, template authors could run restricted static php methods. Users should upgrade to version 3.1.43 or 4.0.3 to receive a patch.
Attack profile
How easy it is to exploit
- Attack vector
- Network
- Complexity
- Low
- Privileges needed
- Low
- User interaction
- None
What an attacker can affect
- Confidentiality
- High
- Integrity
- High
- Availability
- High
Exploit likelihood
What each source reports
CVE List Score used
8.8
Access to restricted PHP code by dynamic static class access in smarty
Smarty is a template engine for PHP, facilitating the separation of presentation (HTML/CSS) from application logic. Prior to versions 3.1.43 and 4.0.3, template authors could run restricted static php methods. Users should upgrade to version 3.1.43 or 4.0.3 to receive a patch.
- Record
CVE-2021-21408- CVSS 3.1
- 8.8 High
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H - Weakness
- CWE-20
- Updated
- 2026-11-02
EUVDEUVD-2022-0443
8.8
Smarty is a template engine for PHP, facilitating the separation of presentation (HTML/CSS) from application logic. Prior to versions 3.1.43 and 4.0.3, template authors could run restricted static php methods. Users should upgrade to version 3.1.43 or 4.0.3 to receive a patch.
- Record
EUVD-2022-0443- CVSS 3.1
- 8.8 High
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H - Updated
- 2026-11-02
GitHub AdvisoriesGHSA-4h9c-v5vg-5m6m
8.8
Access to restricted PHP code by dynamic static class access in smarty
Impact
Template authors could run restricted static php methods.
Patches
Please upgrade to 3.1.40 or higher.
References
See the documentation on Smarty security features on the static_classes access filter.
For more information
If you have any questions or comments about this advisory please open an issue in the Smarty repo
- Record
GHSA-4h9c-v5vg-5m6m- CVSS 3.1
- 8.8 High
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H - Weakness
- CWE-20
- Updated
- 2026-11-02
NVD
8.8
Smarty is a template engine for PHP, facilitating the separation of presentation (HTML/CSS) from application logic. Prior to versions 3.1.43 and 4.0.3, template authors could run restricted static php methods. Users should upgrade to version 3.1.43 or 4.0.3 to receive a patch.
- Record
CVE-2021-21408- CVSS 3.1
- 8.8 High
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H - CVSS 2.0
- 6.5 Medium
AV:N/AC:L/Au:S/C:P/I:P/A:P - Weakness
- CWE-20
- Updated
- 2026-11-02
OSV
8.8
Smarty is a template engine for PHP, facilitating the separation of presentation (HTML/CSS) from application logic. Prior to versions 3.1.43 and 4.0.3, template authors could run restricted static php methods. Users should upgrade to version 3.1.43 or 4.0.3 to receive a patch.
- Record
CVE-2021-21408- CVSS 3.1
- 8.8 High
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H - Updated
- 2026-11-02
OSVDEBIAN-CVE-2021-21408
8.8
Smarty is a template engine for PHP, facilitating the separation of presentation (HTML/CSS) from application logic. Prior to versions 3.1.43 and 4.0.3, template authors could run restricted static php methods. Users should upgrade to version 3.1.43 or 4.0.3 to receive a patch.
- Record
DEBIAN-CVE-2021-21408- CVSS 3.1
- 8.8 High
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H - Updated
- 2026-11-02
Show 6 moreShow less
OSVGHSA-4h9c-v5vg-5m6m
8.8
Access to restricted PHP code by dynamic static class access in smarty
Impact
Template authors could run restricted static php methods.
Patches
Please upgrade to 3.1.40 or higher.
References
See the documentation on Smarty security features on the static_classes access filter.
For more information
If you have any questions or comments about this advisory please open an issue in the Smarty repo
- Record
GHSA-4h9c-v5vg-5m6m- CVSS 3.1
- 8.8 High
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H - Weakness
- CWE-20
- Updated
- 2026-11-02
OSVUBUNTU-CVE-2021-21408
8.8
Smarty is a template engine for PHP, facilitating the separation of presentation (HTML/CSS) from application logic. Prior to versions 3.1.43 and 4.0.3, template authors could run restricted static php methods. Users should upgrade to version 3.1.43 or 4.0.3 to receive a patch.
- Record
UBUNTU-CVE-2021-21408- CVSS 3.1
- 8.8 High
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H - Updated
- 2026-11-02
OSVMGASA-2022-0127 No score
Updated php-smarty packages fix security vulnerability
Updated php-smarty packages to version 4 for php 8 compatibility and to fix security vulnerabilities.
- Record
MGASA-2022-0127- Updated
- 2026-11-02
OSVUSN-5348-1 No score
smarty3 vulnerabilities
David Gnedt and Thomas Konrad discovered that Smarty was incorrectly sanitizing the paths present in the templates. An attacker could possibly use this use to read arbitrary files when controlling the executed template. (CVE-2018-13982)
It was discovered that Smarty was incorrectly sanitizing the paths present in the templates. An attacker could possibly use this use to read arbitrary files when controlling the executed template. (CVE-2018-16831)
It was discovered that Smarty was incorrectly validating security policy data, allowing the execution of static classes even when not permitted by the security settings. An attacker could possibly use this issue to execute arbitrary code. (CVE-2021-21408)
It was discovered that Smarty was incorrectly managing access control to template objects, which allowed users to perform a sandbox escape. An attacker could possibly use this issue to send specially crafted input to applications that use Smarty and execute arbitrary code. (CVE-2021-26119)
It was discovered that Smarty was not checking for special characters when setting function names during plugin compile operations. An attacker could possibly use this issue to send specially crafted input to applications that use Smarty and execute arbitrary code. (CVE-2021-26120)
It was discovered that Smarty was incorrectly sanitizing characters in math strings processed by the math function. An attacker could possibly use this issue to send specially crafted input to applications that use Smarty and execute arbitrary code. (CVE-2021-29454)
- Record
USN-5348-1- Updated
- 2026-11-02
OSVUSN-5348-2 No score
smarty3 vulnerabilities
USN-5348-1 fixed several vulnerabilities in Smarty. This update provides the fixes for CVE-2021-21408, CVE-2021-26119, CVE-2021-26120 and CVE-2021-29454 for Ubuntu 16.04 ESM.
Original advisory details:
David Gnedt and Thomas Konrad discovered that Smarty was incorrectly sanitizing the paths present in the templates. An attacker could possibly use this use to read arbitrary files when controlling the executed template. (CVE-2018-13982)
It was discovered that Smarty was incorrectly sanitizing the paths present in the templates. An attacker could possibly use this use to read arbitrary files when controlling the executed template. (CVE-2018-16831)
It was discovered that Smarty was incorrectly validating security policy data, allowing the execution of static classes even when not permitted by the security settings. An attacker could possibly use this issue to execute arbitrary code. (CVE-2021-21408)
It was discovered that Smarty was incorrectly managing access control to template objects, which allowed users to perform a sandbox escape. An attacker could possibly use this issue to send specially crafted input to applications that use Smarty and execute arbitrary code. (CVE-2021-26119)
It was discovered that Smarty was not checking for special characters when setting function names during plugin compile operations. An attacker could possibly use this issue to send specially crafted input to applications that use Smarty and execute arbitrary code. (CVE-2021-26120)
It was discovered that Smarty was incorrectly sanitizing characters in math strings processed by the math function. An attacker could possibly use this issue to send specially crafted input to applications that use Smarty and execute arbitrary code. (CVE-2021-29454)
- Record
USN-5348-2- Updated
- 2026-11-02
OSVUSN-5348-3 No score
smarty3 vulnerabilities
USN-5348-1 fixed several vulnerabilities in Smarty. This update provides the fixes for CVE-2021-21408, CVE-2021-26119, CVE-2021-26120 and CVE-2021-29454 for Ubuntu 20.04 ESM.
Original advisory details:
David Gnedt and Thomas Konrad discovered that Smarty was incorrectly sanitizing the paths present in the templates. An attacker could possibly use this use to read arbitrary files when controlling the executed template. (CVE-2018-13982)
It was discovered that Smarty was incorrectly sanitizing the paths present in the templates. An attacker could possibly use this use to read arbitrary files when controlling the executed template. (CVE-2018-16831)
It was discovered that Smarty was incorrectly validating security policy data, allowing the execution of static classes even when not permitted by the security settings. An attacker could possibly use this issue to execute arbitrary code. (CVE-2021-21408)
It was discovered that Smarty was incorrectly managing access control to template objects, which allowed users to perform a sandbox escape. An attacker could possibly use this issue to send specially crafted input to applications that use Smarty and execute arbitrary code. (CVE-2021-26119)
It was discovered that Smarty was not checking for special characters when setting function names during plugin compile operations. An attacker could possibly use this issue to send specially crafted input to applications that use Smarty and execute arbitrary code. (CVE-2021-26120)
It was discovered that Smarty was incorrectly sanitizing characters in math strings processed by the math function. An attacker could possibly use this issue to send specially crafted input to applications that use Smarty and execute arbitrary code. (CVE-2021-29454)
- Record
USN-5348-3- Updated
- 2026-11-02
Affected products
Affected packages
| Package | Affected | Fixed |
|---|---|---|
smarty/smartyPackagist |
before 3.1.43 | 3.1.43 |
smarty/smartyPackagist |
4.0.0 up to 4.0.3 | 4.0.3 |
smarty3Debian:12 |
before 3.1.45-1 | 3.1.45-1 |
smarty3Debian:13 |
before 3.1.45-1 | 3.1.45-1 |
smarty3Debian:14 |
before 3.1.45-1 | 3.1.45-1 |
smarty4Debian:12 |
before 4.1.1-1 | 4.1.1-1 |
smarty4Debian:13 |
before 4.1.1-1 | 4.1.1-1 |
smarty4Debian:14 |
before 4.1.1-1 | 4.1.1-1 |
smarty3Debian:9 From an advisory covering 2 CVEs |
before 3.1.31+20161214.1.c7d42e4+selfpack1-2+deb9u5, plus listed versions 3.1.31+20161214.1.c7d42e4+selfpack1-23.1.31+20161214.1.c7d42e4+selfpack1-2+deb9u13.1.31+20161214.1.c7d42e4+selfpack1-2+deb9u23.1.31+20161214.1.c7d42e4+selfpack1-2+deb9u33.1.31+20161214.1.c7d42e4+selfpack1-2+deb9u4 |
3.1.31+20161214.1.c7d42e4+selfpack1-2+deb9u5 |
smarty3Debian:10 From an advisory covering 3 CVEs |
before 3.1.33+20180830.1.3a78a21f+selfpack1-1+deb10u1, plus listed versions 3.1.33+20180830.1.3a78a21f+selfpack1-1 |
3.1.33+20180830.1.3a78a21f+selfpack1-1+deb10u1 |
Show 11 moreShow less
| Package | Affected | Fixed |
|---|---|---|
smarty3Debian:11 From an advisory covering 3 CVEs |
before 3.1.39-2+deb11u1, plus listed versions 3.1.39-13.1.39-2 |
3.1.39-2+deb11u1 |
smarty/smartyPackagist |
before 3.1.43, plus listed versions v2.6.24v2.6.25v2.6.26v2.6.27v2.6.28 Show 36 moreShow lessv2.6.29v2.6.30v2.6.31v2.6.33v3.1.11v3.1.12v3.1.13v3.1.14v3.1.15v3.1.16v3.1.17v3.1.18v3.1.19v3.1.20v3.1.21v3.1.23v3.1.24v3.1.25v3.1.26v3.1.27v3.1.28v3.1.29v3.1.30v3.1.31v3.1.32v3.1.33v3.1.34v3.1.35v3.1.36v3.1.37v3.1.37.1v3.1.38v3.1.39v3.1.40v3.1.41v3.1.42 |
3.1.43 |
smarty/smartyPackagist |
4.0.0 up to 4.0.3, plus listed versions v4.0.0v4.0.1v4.0.2 |
4.0.3 |
php-smartyMageia:8 From an advisory covering 6 CVEs |
before 4.0.4-1.mga8 | 4.0.4-1.mga8 |
smarty3Ubuntu:Pro:16.04:LTS |
before 3.1.21-1ubuntu1+esm1, plus listed versions 3.1.21-13.1.21-1ubuntu1 |
3.1.21-1ubuntu1+esm1 |
smarty3Ubuntu:18.04:LTS |
before 3.1.31+20161214.1.c7d42e4+selfpack1-3ubuntu0.1, plus listed versions 3.1.31+20161214.1.c7d42e4+selfpack1-23.1.31+20161214.1.c7d42e4+selfpack1-3 |
3.1.31+20161214.1.c7d42e4+selfpack1-3ubuntu0.1 |
smarty3Ubuntu:Pro:20.04:LTS |
before 3.1.34+20190228.1.c9f0de05+selfpack1-1ubuntu0.1~esm1, plus listed versions 3.1.33+20180830.1.3a78a21f+selfpack1-13.1.34+20190228.1.c9f0de05+selfpack1-1 |
3.1.34+20190228.1.c9f0de05+selfpack1-1ubuntu0.1~esm1 |
smarty3Ubuntu:22.04:LTS |
before 3.1.39-2ubuntu1, plus listed versions 3.1.39-2 |
3.1.39-2ubuntu1 |
smarty3Ubuntu:18.04:LTS From an advisory covering 6 CVEs |
before 3.1.31+20161214.1.c7d42e4+selfpack1-3ubuntu0.1, plus listed versions 3.1.31+20161214.1.c7d42e4+selfpack1-23.1.31+20161214.1.c7d42e4+selfpack1-3 |
3.1.31+20161214.1.c7d42e4+selfpack1-3ubuntu0.1 |
smarty3Ubuntu:Pro:16.04:LTS From an advisory covering 4 CVEs |
before 3.1.21-1ubuntu1+esm1, plus listed versions 3.1.21-13.1.21-1ubuntu1 |
3.1.21-1ubuntu1+esm1 |
smarty3Ubuntu:Pro:20.04:LTS From an advisory covering 4 CVEs |
before 3.1.34+20190228.1.c9f0de05+selfpack1-1ubuntu0.1~esm1, plus listed versions 3.1.33+20180830.1.3a78a21f+selfpack1-13.1.34+20190228.1.c9f0de05+selfpack1-1 |
3.1.34+20190228.1.c9f0de05+selfpack1-1ubuntu0.1~esm1 |
History
| Recorded | Changed | Sources |
|---|---|---|
| affected, facts | ||
| first indexed | CVE List, EUVD, GitHub Advisories, NVD, OSV |
Dates are when Every CVE recorded each change. Upstream dates may differ.
In short
CVE-2021-21408 is a high vulnerability (CVSS 8.8) in Smarty, published January 10, 2022. No source lists public exploit code. EPSS puts the chance of exploitation in the next 30 days at 2.14%, the 82nd percentile. Fixed in smarty/smarty 3.1.43.
References
github.com/smarty-php/smarty/security/advisories/GHSA-4h9c-v5vg-5m6m
github.com/smarty-php/smarty/commit/19ae410bf56007a5ef24441cdc6414619cfaf664
github.com/smarty-php/smarty/releases/tag/v3.1.43
github.com/smarty-php/smarty/releases/tag/v4.0.3
lists.debian.org/debian-lts-announce/2022/05/msg00005.html
debian.org/security/2022/dsa-5151
Show 23 moreShow less
security.gentoo.org/glsa/202209-09
lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/L777JIBIWJV34HS7LXPIDWASG7TT4LNI
lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/BRAJVDRGCIY5UZ2PQHKDTT7RMKG6WJQQ
nvd.nist.gov/vuln/detail/CVE-2021-21408
lists.fedoraproject.org/archives/list/[email protected]/message/L777JIBIWJV34HS7LXPIDWASG7TT4LNI
lists.fedoraproject.org/archives/list/[email protected]/message/BRAJVDRGCIY5UZ2PQHKDTT7RMKG6WJQQ
github.com/FriendsOfPHP/security-advisories/blob/master/smarty/smarty/CVE-2021-21408.yaml
github.com/advisories/GHSA-4h9c-v5vg-5m6m
security-tracker.debian.org/tracker/CVE-2021-21408
github.com/smarty-php/smarty
advisories.mageia.org/MGASA-2022-0127.html
bugs.mageia.org/show_bug.cgi?id=30214
ubuntu.com/security/notices/USN-5348-1
github.com/smarty-php/smarty/releases/tag/v4.0.4
ubuntu.com/security/CVE-2021-21408
ubuntu.com/security/notices/USN-5348-3
ubuntu.com/security/notices/USN-5348-2
cve.org/CVERecord?id=CVE-2021-21408
ubuntu.com/security/CVE-2018-13982
ubuntu.com/security/CVE-2018-16831
ubuntu.com/security/CVE-2021-26119
ubuntu.com/security/CVE-2021-26120
ubuntu.com/security/CVE-2021-29454