CVE-2024-51754 Unguarded calls to __toString() when nesting an object into an array in Twig

Low 2.2 Published Updated

Attackers can bypass Twig sandbox restrictions to execute unallowed __toString() methods on objects nested in arrays or arguments.

Exploited in the wild
Not known
Login needed
An administrator
Attackable
Over the internet
Victim action needed
Not needed
Fix
Available

What is CVE-2024-51754?

CVE-2024-51754 is a low-severity vulnerability in twigphp Twig, published on 6 Nov 2024. An attacker needs administrator access to exploit it, with no action from the victim.

Official description

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.

Weakness: CWE-668

Which versions are affected by CVE-2024-51754?

4 open source packages ship an affected version, including twig/twig.

PackageAffectedFixed in
twig/twig PackagistAll versions3.11.2
twig/twig PackagistAll versions3.11.2
twig/twig PackagistFrom 3.123.14.1
twig/twig PackagistFrom 3.123.14.1

How do I fix CVE-2024-51754?

Upgrade twig/twig to a fixed version for your release line: 3.11.2 or 3.14.1.

Is CVE-2024-51754 being exploited?

There is no known exploitation of CVE-2024-51754 in the wild and no public exploit code.

Sources

Also known as DEBIAN-CVE-2024-51754, DLA-4186-1, GHSA-6377-hfv9-hqf6, UBUNTU-CVE-2024-51754.

Is CVE-2024-51754 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free