CVE-2025-24374: Twig/twig Twig Security Issue Where Escaping Vulnerability

MODERATE
Advisory Identifier: GHSA-3xg3-cgvq-2xwr
CVSS 4.3
CWE-74
Published
Advisory Summary

CVE-2025-24374 is a MODERATE (CVSS 4.3) twig security issue where escaping vulnerability (CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')) affecting Twig/twig libraries in the Packagist ecosystem. The issue involves twig security issue where escaping was missing when using null coalesce operator. Remediation is available by upgrading affected packages to version 3.19.0.

CVE-2025-24374 at a Glance

CVE Identifier CVE-2025-24374
GHSA Identifier GHSA-3xg3-cgvq-2xwr
Severity MODERATE
CVSS v3.1 Base Score 4.3
CWE Classification CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')
Affected Product Twig/twig
Package Ecosystem Packagist
Published Date
Last Updated

Security Impact

CVSS: 4.3

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

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

How to Fix CVE-2025-24374

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

twig/twig fixed: 3.19.0
Upgrade twig/twig to 3.19.0
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 twig/twig

How to Check if You Are Affected

To determine whether your application is affected by CVE-2025-24374, inspect your project dependencies for Twig/twig:

inspect dependencies for twig/twig

Analyze the terminal output to locate any version of Twig/twig in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.19.0), 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-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection'), where the product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component. In Twig/twig, 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

When using the `??` operator, output escaping was missing for the expression on the left side of the operator.

CVE-2025-24374 Affected Twig/twig Versions

1 component(s)
Fixed Versions:
3.19.0
Product / Package Ecosystem Affected Versions Fixed Version
twig/twig
Packagist
≥ 3.16.0
< 3.19.0
3.19.0

References

Frequently Asked Questions

What is CVE-2025-24374?
CVE-2025-24374 is a security vulnerability in Twig/twig involving Twig security issue where escaping was missing when using null coalesce operator under CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection').
Which Twig/twig versions are affected?
Affected versions include releases prior to 3.19.0 across affected packages: twig/twig.
What version fixes CVE-2025-24374?
Upgrading to 3.19.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is twig/twig affected?
Yes, twig/twig is affected in releases prior to 3.19.0. Upgrade your dependency to 3.19.0 or later.
What is the CVSS score of CVE-2025-24374?
CVE-2025-24374 has a CVSS v3.1 base score of 4.3 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N.
What CWE is associated with CVE-2025-24374?
CVE-2025-24374 is classified under CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection') (The product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.).
How can I check Packagist dependencies for CVE-2025-24374?
Run the dependency tree command: 'inspect dependencies for twig/twig'. 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-3xg3-cgvq-2xwr",
  "modified" : "2025-01-30T15:33:25Z",
  "published" : "2025-01-29T18:41:43Z",
  "aliases" : [ "CVE-2025-24374" ],
  "summary" : "Twig security issue where escaping was missing when using null coalesce operator",
  "details" : "When using the `??` operator, output escaping was missing for the expression on the left side of the operator.\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "twig/twig"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "3.16.0"
      }, {
        "fixed" : "3.19.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/twigphp/Twig/security/advisories/GHSA-3xg3-cgvq-2xwr"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2025-24374"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/twigphp/Twig/commit/38576b12f05df3cc871bf68f39ccb46b418334a3"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/FriendsOfPHP/security-advisories/blob/master/twig/twig/CVE-2025-24374.yaml"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/twigphp/Twig"
  }, {
    "type" : "WEB",
    "url" : "https://symfony.com/blog/twig-cve-2025-24374-missing-output-escaping-for-the-null-coalesce-operator"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-74" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2025-01-29T18:41:43Z",
    "nvd_published_at" : "2025-01-29T16:15:44Z"
  }
}