CVE-2026-24425
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.
AI Insight
LLM-synthesized narrative grounded in this CVE's description and references.
Twig 2.16.x and 3.9.0-3.25.x allow sandbox bypass via SourcePolicyInterface, letting attackers pass arbitrary PHP callables to filters and execute arbitrary code.
Vulnerability
Twig versions 2.16.x and 3.9.0 through 3.25.x contain a sandbox bypass vulnerability affecting the sort, filter, map, and reduce filters. When the sandbox is enabled through a SourcePolicyInterface rather than globally, the runtime check that rejects non-Closure callables does not use the current template Source, allowing user-controlled templates to pass arbitrary PHP callables [1], [2]. The bug exists because the sandbox enforcement is not source-aware in these callback-accepting filters [2].
Exploitation
An attacker with template rendering capabilities must meet all four conditions: (1) sandbox is not enabled globally, (2) a SourcePolicyInterface enables the sandbox for the rendered template, (3) the template uses one of the affected filters, and (4) the callback is not a Closure. Under these conditions, the runtime check incorrectly treats the execution as non-sandboxed, allowing the attacker to supply arbitrary callables such as 'system' or ['Shell', 'exec'] [2].
Impact
Successful exploitation allows an attacker to execute arbitrary PHP code in the context of the application. This leads to full compromise of confidentiality, integrity, and availability — including data disclosure, file manipulation, and remote code execution [2], [3].
Mitigation
The fix was released in Twig v3.26.0 on 2026-05-20, which propagates the current template Source to callback-accepting filters and uses it when deciding whether sandbox restrictions apply [1], [2]. Users should upgrade to 3.26.0 or later. For versions 2.16.x, no patch is explicitly mentioned; users should upgrade to the 3.x branch or apply compatibility changes. No workaround is documented [2].
AI Insight generated on May 21, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.
Affected products
1Patches
0No patches discovered yet.
Vulnerability mechanics
AI mechanics synthesis has not run for this CVE yet.
References
3News mentions
0No linked articles in our index yet.