Advisory Database
  • Advisories
  • Dependency Scanning
  1. composer
  2. ›
  3. twig/twig
  4. ›
  5. CVE-2024-51754

CVE-2024-51754: Twig has unguarded calls to `__toString()` when nesting an object into an array

November 6, 2024 (updated May 29, 2025)

In a sandbox, an attacker can call __toString() on an object even if the __toString() method is not allowed by the security policy when the object is part of an array or an argument list (arguments to a function or a filter for instance).

References

  • github.com/FriendsOfPHP/security-advisories/blob/master/twig/twig/CVE-2024-51754.yaml
  • github.com/advisories/GHSA-6377-hfv9-hqf6
  • github.com/twigphp/Twig
  • github.com/twigphp/Twig/commit/2bb8c2460a2c519c498df9b643d5277117155a73
  • github.com/twigphp/Twig/security/advisories/GHSA-6377-hfv9-hqf6
  • lists.debian.org/debian-lts-announce/2025/05/msg00039.html
  • nvd.nist.gov/vuln/detail/CVE-2024-51754
  • symfony.com/blog/unguarded-calls-to-__tostring-when-nesting-an-object-into-an-array

Code Behaviors & Features

Detect and mitigate CVE-2024-51754 with GitLab Dependency Scanning

Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Dependency Scanning using SBOM also detects vulnerabilities from proprietary advisories that this site does not include. Learn more about Dependency Scanning using SBOM →

Affected versions

All versions before 3.11.2, all versions starting from 3.12 before 3.14.1

Fixed versions

  • 3.11.2
  • 3.14.1

Solution

Upgrade to versions 3.11.2, 3.14.1 or above.

Impact 2.2 LOW

CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:U/C:L/I:N/A:N

Learn more about CVSS

Weakness

  • CWE-668: Exposure of Resource to Wrong Sphere

Source file

packagist/twig/twig/CVE-2024-51754.yml

Spotted a mistake? Edit the file on GitLab.

  • Site Repo
  • About GitLab
  • Terms
  • Privacy Statement
  • Contact

Page generated Sat, 07 Nov 2026 12:17:25 +0000.