CVE-2026-24425
criticalpriority · track · 40EPSS 0.008 · 55 %ileEUUSEPSS · scored 2026-10-28
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.
cvss
Technical severity, 0–10. One row per scoring source.
base score 0–10 · higher = more severe · hover a vector to decode⚠ sources disagree · medium–critical · 6.3–9.9
ssvc
A stakeholder decision — act, attend, or track — from exploitation and impact.
weaknesses
The CWE weakness classes this flaw belongs to.
affected products (6)
Products and version ranges known to be affected.
advisories (1)
Vendor and ecosystem advisories describing this.
- GHSA-2q52-x2ff-qgfrTwig: Possible sandbox bypass when using a source policy2026-06-05ghsa · osvUS
# Description When using the sandbox with a `SourcePolicyInterface`, Twig does not always apply the sandbox restriction that forbids non-`Closure` callbacks for callback-accepting filters. The issue affects the `sort`, `filter`, `map`, and `reduce` filters. In the affected versions, the runtime check that rejects non-`Closure` callbacks in sandbox mode does not use the current template `Source`. As a result, when the sandbox is enabled through a source policy instead of being enabled globally, Twig can incorrectly treat the current execution as non-sandboxed for these callback checks. This can allow user-controlled templates to pass arbitrary PHP callables to callback-accepting filters even though the template is being sandboxed through a source policy. The issue happens when all these conditions are met: - The sandbox is not enabled globally; - A `SourcePolicyInterface` enables the sandbox for the rendered template; - The template uses one of the `sort`, `filter`, `map`, or `reduce` filters; - The callback is not a `Closure`. # Resolution The patch makes callback sandbox checks source-aware by propagating the current template `Source` to callback-accepting filters and using it when deciding whether sandbox restrictions apply. # Credits We would like to thank XavLim and Wade Sparks for reporting the issue and Fabien Potencier for fixing the issue.
also known as (3)
Other names and identifiers for this entity.
sources
Which sources assert this record, and when.
references (8)
External citations — patches, advisories, analysis.
- https://github.com/twigphp/Twig/releasesPatchcnnvd
- https://nvd.nist.gov/vuln/detail/CVE-2026-24425cnnvd
- https://github.com/twigphp/Twig/releases/tag/v3.26.0enisa_euvd
- https://github.com/twigphp/Twig/security/advisories/GHSA-2q52-x2ff-qgfrenisa_euvd
- https://www.vulncheck.com/advisories/twig-x-x-sandbox-bypass-via-sourcepolicyinterfaceenisa_euvd
- https://github.com/twigphp/Twig/releases/tag/v3.26.0ProductRelease Notesnvd
- https://github.com/twigphp/Twig/security/advisories/GHSA-2q52-x2ff-qgfrVendor Advisorynvd
- https://www.vulncheck.com/advisories/twig-x-x-sandbox-bypass-via-sourcepolicyinterfaceThird Party Advisorynvd
Attackers weaponise vulnerabilities like this against internet-exposed services. See what is exposed on your perimeter with a free passive scan.
Free scan