Drupal Core Updates Include Twig 3.31.1 Security Fixes

Security graphic stating that Twig updates reach Drupal sites separately from core, with nine mostly sandbox-related fixes. An illustration stacks Drupal core, Twig templates and Composer layers, with a shield on the Twig layer.

The PHP template engine Twig receives nine security fixes with the release of version 3.31.1 on 24 November 2026, according to an announcement on the Symfony blog. Drupal incorporates the updated library into three core security releases issued the following day.

Twig handles HTML generation through Drupal's templating system. The security disclosures are particularly relevant to maintainers of installations with customised templates and additional Twig packages. Controlled tests conducted by The DropTimes reproduce one of the disclosed defects through Drupal's configured Twig rendering service.

The release notes for Drupal 10.6.23, 11.3.23 and 11.4.14 confirm the inclusion of Twig 3.31.1. The Composer lockfile for Drupal 11.4.14 also specifies version 3.31.1 of twig/html-extra.

Most of the vulnerabilities addressed by Twig 3.31.1 involve sandbox restrictions. Two additional advisories published on 24 November disclose vulnerabilities already fixed in Twig 3.31.0.

Among them is CVE-2026-133771, an autoescaping defect that can lead to cross-site scripting (XSS). Under certain template conditions, Twig fails to escape values associated with a variable whose name matches a macro import alias in another scope. The vulnerability does not require sandboxed templates and was fixed in Twig 3.31.0.

The DropTimes reproduced the autoescaping defect in isolated installations of Drupal 10.6.22, 11.3.22 and 11.4.13 using Twig 3.30.0. Updating Twig to version 3.31.1 corrected the behaviour in all three test environments. The tests used deliberately constructed templates and do not establish exploitability in an unmodified Drupal installation.

The security release also addresses vulnerabilities in additional Twig packages. CVE-2026-133769 affects twig/html-extra and can expose non-public object properties when the sandbox permits the relevant function and method.

The vulnerability is relevant to Drupal 11.4, which introduces HTML Extra as a core dependency to support Class Variance Authority (CVA), a pattern for managing conditional CSS classes in templates.

Another vulnerability, CVE-2026-133773, can cause excessive memory consumption in applications using twig/markdown-extra, particularly those employing long-running workers. Both additional packages receive security fixes in version 3.31.1.

Drupal implements its own Twig sandbox policy, which primarily restricts method calls rather than property access. The presence of an affected package does not, by itself, establish whether an upstream vulnerability is exploitable through Drupal. As of 1 December 2026, the Drupal core security advisory index does not list a dedicated advisory for these Twig vulnerabilities.

Drupal's revised Composer dependency policy allows minor-version updates for selected third-party libraries, including Twig. Introduced in Drupal 11.4, the relaxed dependency constraints were subsequently backported to Drupal 11.3 and 10.6. Site maintainers can therefore apply compatible upstream security fixes independently of Drupal core releases when other dependency requirements permit.

Controlled Composer dependency-resolution tests conducted by The DropTimes using a reconstructed package repository selected Twig 3.31.1 without requiring changes to the tested Drupal core versions. Ordinary page and component rendering remained unchanged across 18 HTML comparisons, although a separate CVA component test produced differences in generated CSS classes.

Repository access restrictions prevented verification of a complete update through standard public Composer repositories and completion of the dependency security audits. The results do not establish compatibility across all Drupal installations.

The Drupal core releases issued on 25 November also address a separate, highly critical installer vulnerability documented in SA-CORE-2026-019. Updating Twig independently does not address that vulnerability. Site maintainers should follow the remediation instructions in the Drupal security advisory.

Maintainers should review their Composer lockfiles and use dependency security audits to identify installed Twig packages that may require updates. Drupal's dependency policy recommends quality assurance before deploying dependency updates to production, particularly where installations use custom themes, contributed extensions or CVA-based components.

The DropTimes conducted these tests using isolated Drupal installations running PHP 8.3.6 and SQLite. Testing and analysis were assisted by AI tooling. The findings are limited to the behaviours examined.

Disclosure: This content is produced with the assistance of AI.

Note: The vision of this web portal is to help promote news and stories around the Drupal community and promote and celebrate the people and organizations in the community. We strive to create and distribute our content based on these content policy. If you see any omission/variation on this please reach out to us at #thedroptimes channel on Drupal Slack and we will try to address the issue as best we can.

Related Organizations

Upcoming Events

Latest Opportunities