CVE-2024-35226: Smarty/smarty Smarty Vulnerable To PHP Code Vulnerability

HIGH
Advisory Identifier: GHSA-4rmg-292m-wg3w
CVSS 7.3
CWE-94
Published
Advisory Summary

CVE-2024-35226 is a HIGH (CVSS 7.3) smarty vulnerable to php code vulnerability (CWE-94: Improper Control of Generation of Code ('Code Injection')) affecting Smarty/smarty libraries in the Packagist ecosystem. The issue involves smarty vulnerable to php code injection by malicious attribute in extends-tag. Remediation is available by upgrading affected packages to version 5.1.1, 4.5.3.

CVE-2024-35226 at a Glance

CVE Identifier CVE-2024-35226
GHSA Identifier GHSA-4rmg-292m-wg3w
Severity HIGH
CVSS v3.1 Base Score 7.3
CWE Classification CWE-94: Improper Control of Generation of Code ('Code Injection')
Affected Product Smarty/smarty
Package Ecosystem Packagist
Published Date
Last Updated

Security Impact

CVSS: 7.3

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:H/I:H/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction Required (UI:R)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability None (A:N)

How to Fix CVE-2024-35226

To remediate this vulnerability, upgrade all affected Smarty/smarty dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

smarty/smarty fixed: 5.1.1
Upgrade smarty/smarty to 5.1.1
smarty/smarty fixed: 4.5.3
Upgrade smarty/smarty to 4.5.3
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for smarty/smarty

How to Check if You Are Affected

To determine whether your application is affected by CVE-2024-35226, inspect your project dependencies for Smarty/smarty:

inspect dependencies for smarty/smarty

Analyze the terminal output to locate any version of Smarty/smarty in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 5.1.1), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-94: Improper Control of Generation of Code ('Code Injection'), where the product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. In Smarty/smarty, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Impact Template authors could inject php code by choosing a malicous file name for an extends-tag. Users that cannot fully trust template authors should update asap. ### Patches Please upgrade to the most recent version of Smarty v4 or v5. There is no patch for v3.

CVE-2024-35226 Affected Smarty/smarty Versions

2 component(s)
Fixed Versions:
5.1.14.5.3
Product / Package Ecosystem Affected Versions Fixed Version
smarty/smarty
Packagist
≥ 5.0.0
< 5.1.1
5.1.1
smarty/smarty
Packagist
≥ 3.0.0
< 4.5.3
4.5.3

References

Frequently Asked Questions

What is CVE-2024-35226?
CVE-2024-35226 is a security vulnerability in Smarty/smarty involving Smarty vulnerable to PHP Code Injection by malicious attribute in extends-tag under CWE-94: Improper Control of Generation of Code ('Code Injection').
Which Smarty/smarty versions are affected?
Affected versions include releases prior to 5.1.1, 4.5.3 across affected packages: smarty/smarty.
What version fixes CVE-2024-35226?
Upgrading to 5.1.1, 4.5.3 (or the latest patched release for your respective branch) resolves the vulnerability.
Is smarty/smarty affected?
Yes, smarty/smarty is affected in releases prior to 5.1.1, 4.5.3. Upgrade your dependency to 5.1.1, 4.5.3 or later.
What is the CVSS score of CVE-2024-35226?
CVE-2024-35226 has a CVSS v3.1 base score of 7.3 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:H/I:H/A:N.
What CWE is associated with CVE-2024-35226?
CVE-2024-35226 is classified under CWE-94: Improper Control of Generation of Code ('Code Injection') (The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.).
How can I check Packagist dependencies for CVE-2024-35226?
Run the dependency tree command: 'inspect dependencies for smarty/smarty'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-4rmg-292m-wg3w",
  "modified" : "2025-11-04T16:50:38Z",
  "published" : "2024-05-29T18:44:30Z",
  "aliases" : [ "CVE-2024-35226" ],
  "summary" : "Smarty vulnerable to PHP Code Injection by malicious attribute in extends-tag",
  "details" : "### Impact\nTemplate authors could inject php code by choosing a malicous file name for an extends-tag. Users that cannot fully trust template authors should update asap.\n\n### Patches\nPlease upgrade to the most recent version of Smarty v4 or v5. There is no patch for v3.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:H/I:H/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "smarty/smarty"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "5.0.0"
      }, {
        "fixed" : "5.1.1"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "smarty/smarty"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "3.0.0"
      }, {
        "fixed" : "4.5.3"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/smarty-php/smarty/security/advisories/GHSA-4rmg-292m-wg3w"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-35226"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/smarty-php/smarty/commit/0be92bc8a6fb83e6e0d883946f7e7c09ba4e857a"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/smarty-php/smarty"
  }, {
    "type" : "WEB",
    "url" : "https://lists.debian.org/debian-lts-announce/2024/11/msg00013.html"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-94" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-05-29T18:44:30Z",
    "nvd_published_at" : "2024-05-28T21:16:30Z"
  }
}