Every CVE Search/ Get API key

CVE-2024-51754

Unguarded calls to __toString() when nesting an object into an array in Twig

2.2 LowFix available

Twig is a template language for PHP. 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). This issue has been patched in versions 3.11.2 and 3.14.1. All users are advised to upgrade. There are no known workarounds for this issue.

Attack profile

How easy it is to exploit

Attack vector
Network
Complexity
High
Privileges needed
High
User interaction
None

What an attacker can affect

Confidentiality
Low
Integrity
None
Availability
None

Exploit likelihood

0.43%Up 0.4 points since Nov 7, 2024
90%50%10%1%

What each source reports

CVE List Score used 2.2

Unguarded calls to __toString() when nesting an object into an array in Twig

Twig is a template language for PHP. 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). This issue has been patched in versions 3.11.2 and 3.14.1. All users are advised to upgrade. There are no known workarounds for this issue.

Record
CVE-2024-51754
CVSS 3.1
2.2 LowCVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:U/C:L/I:N/A:N
Weakness
CWE-668
Updated
2026-11-02
EUVDEUVD-2024-3201 2.2

Twig is a template language for PHP. 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). This issue has been patched in versions 3.11.2 and 3.14.1. All users are advised to upgrade. There are no known workarounds for this issue.

Record
EUVD-2024-3201
CVSS 3.1
2.2 LowCVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:U/C:L/I:N/A:N
Updated
2026-11-02
GitHub AdvisoriesGHSA-6377-hfv9-hqf6 2.1

Twig has unguarded calls to `__toString()` when nesting an object into an array

Description

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).

Resolution

The sandbox mode now checks the __toString() method call on all objects.

The patch for this issue is available here for the 3.11.x branch, and here for the 3.x branch.

Credits

We would like to thank Jamie Schouten for reporting the issue and Fabien Potencier for providing the fix.

Record
GHSA-6377-hfv9-hqf6
CVSS 4.0
2.1 LowCVSS:4.0/AV:N/AC:L/AT:P/PR:H/UI:N/VC:L/VI:N/VA:N/SC:N/SI:N/SA:N
CVSS 3.1
2.2 LowCVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:U/C:L/I:N/A:N
Weakness
CWE-668
Updated
2026-11-02
NVD 2.2

Twig is a template language for PHP. 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). This issue has been patched in versions 3.11.2 and 3.14.1. All users are advised to upgrade. There are no known workarounds for this issue.

Record
CVE-2024-51754
CVSS 3.1
2.2 LowCVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:U/C:L/I:N/A:N
Weakness
CWE-668
Updated
2026-11-02
OSV 2.2

Unguarded calls to __toString() when nesting an object into an array in Twig

Twig is a template language for PHP. 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). This issue has been patched in versions 3.11.2 and 3.14.1. All users are advised to upgrade. There are no known workarounds for this issue.

Record
CVE-2024-51754
CVSS 3.1
2.2 LowCVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:U/C:L/I:N/A:N
Weakness
CWE-668
Updated
2026-11-02
OSVDEBIAN-CVE-2024-51754 2.2

Twig is a template language for PHP. 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). This issue has been patched in versions 3.11.2 and 3.14.1. All users are advised to upgrade. There are no known workarounds for this issue.

Record
DEBIAN-CVE-2024-51754
CVSS 3.1
2.2 LowCVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:U/C:L/I:N/A:N
Updated
2026-11-02
Show 6 moreShow less
OSVGHSA-6377-hfv9-hqf6 2.1

Twig has unguarded calls to `__toString()` when nesting an object into an array

Description

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).

Resolution

The sandbox mode now checks the __toString() method call on all objects.

The patch for this issue is available here for the 3.11.x branch, and here for the 3.x branch.

Credits

We would like to thank Jamie Schouten for reporting the issue and Fabien Potencier for providing the fix.

Record
GHSA-6377-hfv9-hqf6
CVSS 4.0
2.1 LowCVSS:4.0/AV:N/AC:L/AT:P/PR:H/UI:N/VC:L/VI:N/VA:N/SC:N/SI:N/SA:N
CVSS 3.1
2.2 LowCVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:U/C:L/I:N/A:N
Weakness
CWE-668
Updated
2026-11-02
OSVUBUNTU-CVE-2024-51754 2.2

Twig is a template language for PHP. 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). This issue has been patched in versions 3.11.2 and 3.14.1. All users are advised to upgrade. There are no known workarounds for this issue.

Record
UBUNTU-CVE-2024-51754
CVSS 3.1
2.2 LowCVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:U/C:L/I:N/A:N
Updated
2026-11-02
OSVCLSA-2026-1783991054 No score

TuxCare security update for twig/twig (11 CVEs)

TuxCare rebuilt twig/twig to address 11 CVEs. Fixed in v2.16.1-p1+tuxcare.

Record
CLSA-2026-1783991054
Updated
2026-11-02
OSVCLSA-2026-1784682913 No score

TuxCare security update for twig/twig (10 CVEs)

TuxCare rebuilt twig/twig to address 10 CVEs. Fixed in v2.15.6-p2+tuxcare.

Record
CLSA-2026-1784682913
Updated
2026-11-02
OSVCLSA-2026-1786534048 No score

TuxCare security update for twig/twig (8 CVEs)

TuxCare rebuilt twig/twig to address 8 CVEs. Fixed in v1.44.8-p1+tuxcare.

Record
CLSA-2026-1786534048
Updated
2026-11-02
OSVUSN-7456-1 No score

php-twig vulnerabilities

Fabien Potencier discovered that Twig did not run sandbox security checks in some circumstances. An attacker could possibly use this issue to cause a denial of service or execute arbitrary commands. This issue only affected Ubuntu 22.04 LTS and Ubuntu 24.04 LTS. (CVE-2024-45411)

Jamie Schouten discovered that Twig could bypass the security policy for an object call. An attacker could possibly use this issue to obtain sensitive information. (CVE-2024-51754)

Record
USN-7456-1
Updated
2026-11-02

Affected products

Affected packages

Affected packages
PackageAffectedFixed
twig/twig
Packagist
before 3.11.2
3.11.2
twig/twig
Packagist
3.12 up to 3.14.1
3.14.1
twig/twig
TuxCare:Packagist
From an advisory covering 11 CVEs
v2.16.1 up to v2.16.1-p1+tuxcare
v2.16.1-p1+tuxcare
twig/twig
TuxCare:Packagist
From an advisory covering 10 CVEs
v2.15.6 up to v2.15.6-p2+tuxcare, plus listed versions
v2.15.6-p1+tuxcare
v2.15.6-p2+tuxcare
twig/twig
TuxCare:Packagist
From an advisory covering 8 CVEs
v1.44.8 up to v1.44.8-p1+tuxcare
v1.44.8-p1+tuxcare
php-twig
Debian:12
before 3.5.1-1+deb12u3, plus listed versions
3.5.1-13.5.1-1+deb12u13.5.1-1+deb12u2
3.5.1-1+deb12u3
php-twig
Debian:13
before 3.14.2-1
3.14.2-1
php-twig
Debian:14
before 3.14.2-1
3.14.2-1
php-twig
Debian:11
before 2.14.3-1+deb11u4, plus listed versions
2.14.3-12.14.3-1+deb11u12.14.3-1+deb11u22.14.3-1+deb11u3
2.14.3-1+deb11u4
twig/twig
Packagist
before 3.11.2, plus listed versions
1.3.01.4.01.5.01.5.11.6.0
Show 45 moreShow less
1.6.11.6.21.6.31.6.41.6.5v1.10.0v1.10.1v1.10.2v1.10.3v1.11.0v1.11.1v1.12.0v1.12.0-RC1v1.12.1v1.12.2v1.12.3v1.13.0v1.13.1v1.13.2v1.14.0v1.14.1v1.14.2v1.15.0v1.15.1v1.16.0v1.16.1v1.16.2v1.16.3v1.17.0v1.18.0v1.18.1v1.18.2v1.19.0v1.20.0v1.21.0v1.21.1v1.21.2v1.22.0v1.22.1v1.22.2v1.22.3v1.23.0v1.23.1v1.23.2v1.23.3
3.11.2
Show 9 moreShow less
Affected packages
PackageAffectedFixed
twig/twig
Packagist
3.12 up to 3.14.1, plus listed versions
v3.12.0v3.13.0v3.14.0
3.14.1
twig
Ubuntu:Pro:16.04:LTS
All versions, plus listed versions
1.20.0-11.23.1-1ubuntu11.23.1-1ubuntu41.23.1-1ubuntu4+esm1
None known
twig
Ubuntu:Pro:18.04:LTS
All versions, plus listed versions
1.24.0-2ubuntu12.4.4-2ubuntu12.4.6-12.4.6-1ubuntu0.1~esm1
None known
php-twig
Ubuntu:Pro:20.04:LTS
before 2.12.5-1ubuntu0.1~esm2, plus listed versions
2.11.3-22.12.1-12.12.2-12.12.3-12.12.5-12.12.5-1ubuntu0.1~esm1
2.12.5-1ubuntu0.1~esm2
php-twig
Ubuntu:Pro:22.04:LTS
before 3.3.8-2ubuntu4+esm2, plus listed versions
3.3.2-1ubuntu33.3.4-13.3.6-13.3.7-13.3.8-2ubuntu43.3.8-2ubuntu4+esm1
3.3.8-2ubuntu4+esm2
php-twig
Ubuntu:Pro:24.04:LTS
before 3.8.0-2ubuntu0.1~esm1, plus listed versions
3.7.0-13.7.1-13.8.0-2
3.8.0-2ubuntu0.1~esm1
php-twig
Ubuntu:Pro:20.04:LTS
From an advisory covering 2 CVEs
before 2.12.5-1ubuntu0.1~esm2, plus listed versions
2.11.3-22.12.1-12.12.2-12.12.3-12.12.5-12.12.5-1ubuntu0.1~esm1
2.12.5-1ubuntu0.1~esm2
php-twig
Ubuntu:Pro:22.04:LTS
From an advisory covering 2 CVEs
before 3.3.8-2ubuntu4+esm2, plus listed versions
3.3.2-1ubuntu33.3.4-13.3.6-13.3.7-13.3.8-2ubuntu43.3.8-2ubuntu4+esm1
3.3.8-2ubuntu4+esm2
php-twig
Ubuntu:Pro:24.04:LTS
From an advisory covering 2 CVEs
before 3.8.0-2ubuntu0.1~esm1, plus listed versions
3.7.0-13.7.1-13.8.0-2
3.8.0-2ubuntu0.1~esm1

History

History
RecordedChangedSources
affected, facts
first indexedCVE List, EUVD, GitHub Advisories, NVD, OSV

Dates are when Every CVE recorded each change. Upstream dates may differ.

In short

CVE-2024-51754 is a low vulnerability (CVSS 2.2) in Twigphp Twig, published November 6, 2024. No source lists public exploit code. EPSS puts the chance of exploitation in the next 30 days at 0.43%, the 37th percentile. Fixed in twig/twig 3.11.2.

References

Show 8 moreShow less
This page doesn't list everything

Left out here: 170 versions. The JSON record has them.

MoveEnter Open