CVE-2026-46629
JSON

5.3medium

Twig: Unbounded formatter memoisation in twig/intl-extra keyed on template-controlled arguments

Severity
5.3medium CVSS:4.0 by GitHub_M
Exploit likelihood
0.54% (higher than 39% of CVEs)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-35wc-cvqg-78fp

Description

Twig is a template language for PHP. Prior to 3.26.0, twig/intl-extra memoises IntlDateFormatter and NumberFormatter instances in arrays keyed by template-controlled filter arguments such as locale, pattern, and attrs, allowing a template to allocate many ICU formatter objects that remain pinned for the lifetime of the Twig\Environment. This issue is fixed in version 3.26.0.

Affected

Product or packageVersionsReported by
twigphp Twig< 3.26.0CVE List
twig/intl-extra (Packagist)before 3.26.0GitHub Advisory Database
symfony twigbefore 3.26.0NVD

All scores

GitHub_M5.3medium CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N
GitHublow CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N/E:U
NVD6.5medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H

Classification

CWE-770

SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial.

What each source says

CVE List

Twig is a template language for PHP. Prior to 3.26.0, twig/intl-extra memoises IntlDateFormatter and NumberFormatter instances in arrays keyed by template-controlled filter arguments such as locale, pattern, and attrs, allowing a template to allocate many ICU formatter objects that remain pinned for the lifetime of the Twig\Environment. This issue is fixed in version 3.26.0.

GitHub Advisory Database
Description

IntlExtension memoises every \IntlDateFormatter and \NumberFormatter it creates in instance-level arrays keyed on a hash that includes locale, pattern, attrs and other values that are ordinary named arguments of the format_datetime / format_date / format_time / format_number / format_currency filters. There is no size limit and no eviction.

A template that iterates over many distinct pattern (or locale, or grouping_used, ...) values therefore allocates one ICU formatter object per distinct value and pins it for the entire lifetime of the Twig\Environment. Because ICU allocates its backing buffers outside the Zend memory manager, this growth is not bounded by memory_limit. On long-running runtimes (RoadRunner, Swoole, FrankenPHP worker mode, ReactPHP) where the Environment outlives a single request, the cache also accumulates across requests.

Resolution

The formatter caches are now bounded in size (100 entries each) and evict on a FIFO basis.

Credits

Twig would like to thank Claude Mythos Preview (via Project Glasswing) for reporting the issue and providing the fix.

NVD (es)

Twig es un lenguaje de plantillas para PHP. Antes de la versión 3.26.0, twig/intl-extra memoriza instancias de IntlDateFormatter y NumberFormatter en arrays indexados por argumentos de filtro controlados por la plantilla, como la configuración regional, el patrón y los atributos, permitiendo que una plantilla asigne muchos objetos formateadores ICU que permanecen anclados durante la vida útil del Twig\Environment. Este problema está solucionado en la versión 3.26.0.

References

Sources

SourceRecordLicence
CVE ListCVE-2026-46629 changed 2026-07-15CVE Terms of Use
GitHub Advisory DatabaseGHSA-35wc-cvqg-78fp changed 2026-09-10CC-BY-4.0
NVDCVE-2026-46629 changed 2026-10-24Public domain