CVE-2025-24374 Twig fixes a security issue where escaping was missing when using null coalesce operator (??)

Medium 4.3 Published Updated

Missing output escaping in Twig's null coalesce operator allows attackers to inject malicious scripts, potentially leading to cross-site scripting attacks.

Exploited in the wild
Not known
Login needed
Not needed
Attackable
Over the internet
Victim action needed
A user has to click or open something
Fix
Available

What is CVE-2025-24374?

CVE-2025-24374 is a medium-severity cross-site scripting vulnerability in twigphp Twig, published on 29 Jan 2025. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.

Official description

Twig is a template language for PHP. When using the ?? operator, output escaping was missing for the expression on the left side of the operator. This vulnerability is fixed in 3.19.0.

Weakness: CWE-74

Which versions are affected by CVE-2025-24374?

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

PackageAffectedFixed in
twig/twig PackagistFrom 3.16.03.19.0
twig/twig PackagistFrom 3.16.03.19.0

How do I fix CVE-2025-24374?

Upgrade twig/twig to 3.19.0 or later.

Escape output for the context it lands in and set a strict Content Security Policy. Upgrading the affected component is the real fix. More about Cross-site scripting.

Is CVE-2025-24374 being exploited?

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

Sources

Also known as DEBIAN-CVE-2025-24374, GHSA-3xg3-cgvq-2xwr, UBUNTU-CVE-2025-24374.

Is CVE-2025-24374 in your software?

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

Check your SBOMs for free