# CVE-2026-24425: Twig PHP sandbox bypass in SourcePolicyInterface

Source: https://junglewise.ai/threats/cve-2026-24425-twig-php-sandbox-bypass-in-sourcepolicyinterface  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2026-05-20. Updated: 2026-06-05  
License: CC BY 4.0 with a link back

CVE-2026-24425 · Severity: high · CVSS 8.8 · Published 2026-05-20

A vulnerability in the Twig template engine could allow an attacker to bypass security restrictions designed to isolate untrusted code. Twig is a popular tool used by web applications to generate dynamic content. If exploited, an attacker could execute unauthorized commands on the server, potentially leading to a full system takeover or theft of sensitive data.

Technologies: [twig/twig (Packagist)](https://junglewise.ai/threats/technologies/twig-twig), [Twig PHP Twig](https://junglewise.ai/threats/technologies/twig). Vendors: [Packagist](https://junglewise.ai/threats/vendors/packagist), [Twig PHP](https://junglewise.ai/threats/vendors/twig-php).

## Quick answers

**Is CVE-2026-24425 exploited in the wild?** No. Junglewise Threat Intelligence has no report of CVE-2026-24425 being exploited in the wild.

**How severe is CVE-2026-24425?** High severity, with a CVSS score of 8.8, published 20 May 2026.

**Which products and versions are affected?** twig/twig (Packagist) ECOSYSTEM:introduced=2.16.0,last_affected=2.16.1; Twig PHP Twig 2.16.x, 3.9.0 to 3.25.x.

**Is there a fix for CVE-2026-24425?** A patch was published on 2026-06-05: Fixed in version 3.26.0 Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is CVE-2026-24425 attacked?** It is attacked over the network, in a software library.

**Am I affected by CVE-2026-24425?** Check whether you run twig/twig (Packagist) or Twig PHP Twig at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## Technical details

A sandbox bypass exists in Twig when the sandbox is enabled via a SourcePolicyInterface rather than globally. The vulnerability stems from a failure in the runtime check for callback-accepting filters (specifically sort, filter, map, and reduce) to verify the current template Source. This allows an attacker to pass arbitrary PHP callables instead of being restricted to Closure objects. Exploitation requires the ability to provide or modify a template that is processed under a source-based sandbox policy. The issue is resolved in version 3.26.0 by making callback sandbox checks source-aware.

## Affected products

- twigphp Twig >= 2.16.0, <= 2.16.1
- twigphp Twig >= 3.9.0, < 3.26.0

## Identifiers

- CVE-2026-24425
- GHSA-2q52-x2ff-qgfr

## Timeline

- 2026-05-20: disclosed
- 2026-06-05: advisory
- 2026-06-05: patched: Fixed in version 3.26.0

## References

- [https://api.github.com/users/fabpot](https://api.github.com/users/fabpot)
- [https://github.com/fabpot](https://github.com/fabpot)
- [https://api.github.com/users/fabpot/gists%7B/gist_id%7D](https://api.github.com/users/fabpot/gists%7B/gist_id%7D)
- [https://api.github.com/users/fabpot/repos](https://api.github.com/users/fabpot/repos)
- [https://avatars.githubusercontent.com/u/47313?v=4](https://avatars.githubusercontent.com/u/47313?v=4)
- [https://api.github.com/users/fabpot/events%7B/privacy%7D](https://api.github.com/users/fabpot/events%7B/privacy%7D)

## Related threats

- [Twig sandbox allow-list bypass via template cache reuse](https://junglewise.ai/threats/cve-2026-49981-twig-sandbox-allow-list-bypass-via-template-cache-reuse)
- [Twig sandbox bypass in column filter via SourcePolicyInterface](https://junglewise.ai/threats/cve-2026-48808-twig-sandbox-bypass-in-column-filter-via-sourcepolicyinterface)
- [Twig sandbox policy bypass via Traversable objects in filters and operators](https://junglewise.ai/threats/cve-2026-48807-twig-sandbox-policy-bypass-via-traversable-objects-in-filters-and)
- [Twig sandbox policy bypass via dynamic mapping keys](https://junglewise.ai/threats/cve-2026-48806-twig-sandbox-policy-bypass-via-dynamic-mapping-keys)
- [Twig sandbox bypass in deprecated internal wrappers](https://junglewise.ai/threats/cve-2026-48805-twig-sandbox-bypass-in-deprecated-internal-wrappers)
