Vulnerability record · CVE-2021-26120 · published 22 February 2021
CVE-2021-26120: Smarty template engine code injection via function name
Smarty · Smarty
Smarty before 3.1.39 allows code injection through an unexpected function name following a {function name= substring in a template. Because Smarty is a PHP template engine, injected code executes in the context of the hosting application, making this a serious remote code execution risk wherever untrusted template content is processed.
Description
Smarty before 3.1.39 allows code injection via an unexpected function name after a {function name= substring.
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
Automated analysis
critical priorityCVSS 9.8 with network reachability, no authentication or interaction, and full code execution impact, plus a very high EPSS score, make this an urgent patch target despite no KEV listing.
What it is
Smarty before 3.1.39 allows code injection through an unexpected function name following a {function name= substring in a template. Because Smarty is a PHP template engine, injected code executes in the context of the hosting application, making this a serious remote code execution risk wherever untrusted template content is processed.
Impact
An attacker can inject and execute arbitrary code in the PHP process running the application, leading to full compromise of confidentiality, integrity and availability of the affected host.
Attack surface
The flaw is reachable over the network with no authentication and no user interaction per the CVSS vector (AV:N/AC:L/PR:N/UI:N). It is triggered by supplying crafted template content containing a {function name= substring, so any application that lets untrusted input reach Smarty template compilation is exposed.
Exploitation
Not listed in CISA KEV and no ransomware associations are documented, but EPSS is very high at 0.823 (99.6th percentile), indicating strong predicted exploitation activity. Reference tags are release notes, mailing lists and patch advisories only; no public exploit reference is included in the record.
What to do
- Upgrade Smarty to 3.1.39 or later; apply the vendor release containing the fix.
- Apply the Debian and Gentoo security updates (DSA-5151, GLSA 202105-06) on distributions shipping the affected package.
- Do not pass user-controlled or otherwise untrusted content into Smarty templates; treat template sources as trusted code.
- Where feasible, sandbox or restrict the PHP process running Smarty to limit the blast radius of code execution.
Detection
- Search application and web logs for template input containing the string {function name= or unusual function names in template parameters.
- Monitor for unexpected child processes, outbound connections or file writes originating from the PHP/web server process.
- Audit template storage and upload paths for recently modified or newly introduced template files.
- Alert on Smarty version strings below 3.1.39 in deployed applications and dependency manifests.
This assessment is produced automatically and is not human-reviewed. Verify against the vendor advisory before acting on it.
Affected products
2 vulnerable configurations from NVD's CPE data, grouped by vendor and product.
References
| Link | Tags |
|---|---|
| https://github.com/smarty-php/smarty/blob/master/CHANGELOG.md | Release NotesThird Party Advisory |
| https://lists.debian.org/debian-lts-announce/2021/04/msg00004.html | Mailing ListThird Party Advisory |
| https://lists.debian.org/debian-lts-announce/2021/04/msg00014.html | Mailing ListThird Party Advisory |
| https://security.gentoo.org/glsa/202105-06 | PatchThird Party Advisory |
| https://www.debian.org/security/2022/dsa-5151 | Third Party Advisory |
| https://github.com/smarty-php/smarty/blob/master/CHANGELOG.md | Release NotesThird Party Advisory |
| https://lists.debian.org/debian-lts-announce/2021/04/msg00004.html | Mailing ListThird Party Advisory |
| https://lists.debian.org/debian-lts-announce/2021/04/msg00014.html | Mailing ListThird Party Advisory |
| https://security.gentoo.org/glsa/202105-06 | PatchThird Party Advisory |
| https://www.debian.org/security/2022/dsa-5151 | Third Party Advisory |
Track CVE-2021-26120 inside VULONE
Watch it alongside the ransomware crews, C2 infrastructure and forum chatter that reference it, query it through the API and pull it into your SIEM over TAXII.
Related vulnerabilities
Same products first, then exploited flaws of the same weakness class.
Source: NIST National Vulnerability Database (record CVE-2021-26120), CISA KEV, FIRST EPSS (scores of 2026-09-26). This page is refreshed as NVD updates the record.