Skip to main content
Press slash or control plus K to focus the search. Use the arrow keys to navigate results and press enter to open a threat.
Reconnecting to live updates…

CVE-2024-35226: CWE-94: Improper Control of Generation of Code ('Code Injection') in smarty-php smarty

0
High
VulnerabilityCVE-2024-35226cvecve-2024-35226cwe-94
Published: Tue May 28 2024 (05/28/2024, 20:55:00 UTC)
Source: CVE Database V5
Vendor/Project: smarty-php
Product: smarty

Description

Smarty is a template engine for PHP, facilitating the separation of presentation (HTML/CSS) from application logic. In affected versions template authors could inject php code by choosing a malicious file name for an extends-tag. Sites that cannot fully trust template authors should update asap. All users are advised to update. There is no patch for users on the v3 branch. There are no known workarounds for this vulnerability.

AI-Powered Analysis

AILast updated: 11/04/2025, 00:02:54 UTC

Technical Analysis

CVE-2024-35226 is a code injection vulnerability classified under CWE-94 affecting the Smarty PHP template engine, a widely used tool that separates presentation logic from application logic. The vulnerability arises from improper control over the generation of code via the extends-tag in templates. Specifically, a malicious template author can craft a filename for the extends-tag that includes PHP code, which Smarty then executes, leading to arbitrary code execution within the context of the web server. This flaw affects Smarty versions from 3.0.0 up to but not including 4.5.3, and versions from 5.0.0 up to but not including 5.1.1. Notably, there is no patch available for users on the v3 branch, and no known workarounds exist, making upgrading or restricting template author capabilities critical. The vulnerability requires at least limited privileges (template author role) and user interaction to exploit, but once exploited, it can compromise confidentiality and integrity of the application and underlying system. The CVSS v3.1 score is 7.3, reflecting high severity due to network attack vector, low attack complexity, required privileges, and user interaction. No known exploits are currently observed in the wild, but the risk remains significant given the potential impact and lack of mitigations for older branches.

Potential Impact

For European organizations, the impact of CVE-2024-35226 can be severe, particularly for those relying on Smarty in web applications that allow multiple template authors or third-party template contributions. Successful exploitation can lead to arbitrary PHP code execution, enabling attackers to access sensitive data, modify application behavior, or pivot to further internal network compromise. Confidentiality is at high risk as attackers can read sensitive configuration files or databases. Integrity is also highly impacted since attackers can alter application logic or data. Although availability impact is not directly indicated, secondary effects such as data corruption or service disruption could occur. Organizations in sectors with high web presence such as finance, e-commerce, government, and media are especially vulnerable. The lack of patches for older versions means legacy systems remain exposed, increasing the attack surface. Given the widespread use of PHP and Smarty in Europe, the threat could affect a broad range of enterprises and public sector entities.

Mitigation Recommendations

1. Upgrade Smarty to the latest patched versions: For v4 and v5 branches, update to versions >=4.5.3 and >=5.1.1 respectively as soon as they become available. 2. For users on the unsupported v3 branch, consider migrating to a supported version promptly since no patches exist. 3. Restrict template author privileges strictly to trusted personnel only; avoid allowing untrusted or external contributors to upload or modify templates. 4. Implement rigorous input validation and sanitization on template filenames and any user-supplied data used in templates to prevent injection of malicious code. 5. Employ runtime application self-protection (RASP) or web application firewalls (WAFs) with custom rules to detect and block suspicious template-related requests. 6. Conduct code reviews and security audits of templates before deployment to identify potential injection vectors. 7. Monitor logs for unusual template loading or execution patterns that could indicate exploitation attempts. 8. Isolate web application environments to limit the impact of potential code execution. 9. Educate developers and template authors about secure template practices and the risks of code injection.

Need more detailed analysis?Get Pro

Technical Details

Data Version
5.2
Assigner Short Name
GitHub_M
Date Reserved
2024-05-14T15:39:41.784Z
Cvss Version
3.1
State
PUBLISHED

Threat ID: 69092624fe7723195e0b47c6

Added to database: 11/3/2025, 10:01:08 PM

Last enriched: 11/4/2025, 12:02:54 AM

Last updated: 11/5/2025, 2:10:30 PM

Views: 1

Community Reviews

0 reviews

Crowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.

Sort by
Loading community insights…

Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.

Actions

PRO

Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.

Please log in to the Console to use AI analysis features.

Need enhanced features?

Contact root@offseq.com for Pro access with improved analysis and higher rate limits.

Latest Threats