# Twig: Sandbox filter, tag and function allow-list bypass when sandbox state changes between renders for a cached `Template`

High severity, published 2026-07-01. Update twig/twig to 3.27.0 or later: composer update twig/twig.

Canonical URL: https://buzzphp.com/security/ghsa-529h-vh3j-85hq · Data from GitHub as of 2026-11-25.

| | |
| --- | --- |
| Severity | high |
| Published | 2026-07-01 |
| Updated | 2026-07-01 |
| CVE | [CVE-2026-49981](https://nvd.nist.gov/vuln/detail/CVE-2026-49981) |
| GHSA | [GHSA-529h-vh3j-85hq](https://github.com/advisories/GHSA-529h-vh3j-85hq) |
| Weakness | CWE-693, CWE-863 |

| Package | Affected versions | Fixed in |
| --- | --- | --- |
| twig/twig | <= 3.26.0 | 3.27.0 |

## What to do

Update twig/twig to 3.27.0 or later: composer update twig/twig.

Check which version you run with `composer show twig/twig`, and every affected package with `composer audit`.

## About this advisory

Description

The per-template filter, tag and function allow-list check is compiled into the checkSecurity() method of each Template subclass and was invoked once from the constructor, gated by SandboxExtension::isSandboxed($source). Template instances are then cached on the Environment in $loadedTemplates, so the verdict computed at construction time was sticky for the rest of the process.



## Links

- [GHSA-529h-vh3j-85hq on GitHub](https://github.com/advisories/GHSA-529h-vh3j-85hq)
- [CVE-2026-49981 on the National Vulnerability Database](https://nvd.nist.gov/vuln/detail/CVE-2026-49981)
- [All Composer security advisories](https://buzzphp.com/security)
