Arbitrary PHP execution via unvalidated math expressions
Published Jan 10, 2022 · Updated Apr 23, 2025
Code injection in Smarty before 3.1.42 and 4.0.0 through 4.0.1 allows attackers to execute arbitrary PHP via crafted math strings. The smarty_function_math function passes its equation parameter directly to PHP eval after checks that do not enforce a valid mathematical grammar. Reachability requires a template author or an embedding application to pass attacker-controlled data as the equation, after which code runs with the PHP process's privileges.
Summary
What happened
Code injection in Smarty before 3.1.42 and 4.0.0 through 4.0.1 allows attackers to execute arbitrary PHP via crafted math strings. The smarty_function_math function passes its equation parameter directly to PHP eval after checks that do not enforce a valid mathematical grammar. Reachability requires a template author or an embedding application to pass attacker-controlled data as the equation, after which code runs with the PHP process's privileges.
The record
- CVE
- CVE-2021-29454
- Published
- Jan 10, 2022
- Updated
- Apr 23, 2025
- Vendor
- Smarty
- Product
- Smarty
- Classifications
- CWE-74, T1059
- Attack vector
- network
- Privileges
- unauthenticated
Timeline
How it unfolded
- Jan 10, 2022CVE publishedPublication date reported by the CVE source.
- Apr 23, 2025Record updatedLatest update available in the CVE record.
Exploitability
Present is not the same as exploitable
Compare your product and version with the public record. A matching version still requires validation against your environment.
Is a vulnerable build present?
Compare these published version ranges with your installed build and any vendor patches.
- Affected versionversion=< 3.1.42
- Affected versionversion=>= 4.0.0, < 4.0.2
What conditions does exploitation require?
What is affected?
Published CVSS scores
CVSS describes severity. EPSS estimates exploitation probability.
Attacks
What attackers are doing with it
Daily unique IPs observed by Shadowserver honeypots for known exploited vulnerabilities (KEVs). Missing observations do not establish an absence of attacks.
Weakness, pattern, technique
Public exploit references
No public exploit references are available in this record.
Labels summarize the accepted research assessment. They do not indicate a test against your environment.
Technologies
Your stack
See the directory against your own environment.
Your stack
Check the software in your environment
Book a demo to see how Hinoki identifies affected software and validates exploitability in your environment.
Book a demo