Description
Twig versions 2.16.x and 3.9.0 through 3.25.x contain a sandbox bypass vulnerability when using a SourcePolicyInterface that allows attackers with template rendering capabilities to pass arbitrary PHP callables to sort, filter, map, and reduce filters. Attackers can exploit the runtime check that fails to use the current template source to bypass sandbox restrictions and execute arbitrary code when the sandbox is enabled through a source policy rather than globally.
Affected products
| Vendor | Product | Affected | Fixed |
|---|---|---|---|
| twigphp | Twig | 3.9.0 – < 3.26.0, 2.16.* | 3.26.0 |
Fixed in Linux distributions
Distributions backport fixes, so the version that fixes this vulnerability differs per release — upgrade to at least the version shown. From the distributions' security trackers and advisories.
Debian
Security tracker ↗| Release | Package | Fixed in | Advisory |
|---|---|---|---|
| Debian 14 | php-twig | 3.26.0-1 | — |
| Debian 13 | php-twig | 3.27.0-0+deb13u1 | — |
Ubuntu
Security tracker ↗| Release | Package | Fixed in | Advisory |
|---|---|---|---|
| Ubuntu 25.10 | php-twig | No fix yet | — |
Show 1 more (older releases, extended support, other products)Fewer releases
| Release | Package | Fixed in | Advisory |
|---|---|---|---|
| Ubuntu Pro 26.04 LTS | php-twig | 3.23.0-2ubuntu0.1~esm1 | USN-8408-1 |
Affected packages
| Ecosystem | Package | Affected | Fixed | Record |
|---|---|---|---|---|
| Packagist | twig/twig | >= 2.16.0, <= 2.16.1 | — | GHSA-2q52-x2ff-qgfr |
| Packagist | twig/twig | >= 3.9.0, < 3.26.0 | 3.26.0 | GHSA-2q52-x2ff-qgfr |
Advisories 1
- USN-8408-1 php-twig vulnerability Ubuntu Security Notices (USN) · Jun 9, 2026
References
- GitHub Security Advisory (GHSA-2q52-x2ff-qgfr) vendor-advisory
- Twig 3.26.0 Release Notes release-notes
- https://www.vulncheck.com/advisories/twig-x-x-sandbox-bypass-via-sourcepolicyinterface third-party-advisory