CVE-2026-48807 is a critical sandbox bypass (CVSS 9.1) in Twig. Before 3.27.0, the sandbox string checks did not cover Traversable values given to the join and replace filters, or operands of the in and not in operators. Upgrade to Twig 3.27.0 if untrusted users write sandboxed templates.
What's affected
Twig 3.26.0 and earlier, patched in 3.27.0.
The issue matters for applications that run untrusted template code in the sandbox. The advisory says the gap covers two spots: Traversable values passed to join and replace, and the in and not in operators, with both array and Traversable haystacks.
How to check if you're exposed
Check the installed version and whether you use the sandbox.
composer show twig/twig
composer why twig/twig
The second command shows which packages, such as Symfony bundles, pull Twig in. Check the sandbox: search your code for SandboxExtension or SecurityPolicy, because only sandboxed templates are in scope.
What to do now
- Run
composer update twig/twigand confirm the installed version is 3.27.0 or later. - Redeploy, and clear template caches so compiled templates are rebuilt.
- If you let users or editors author templates, review what objects and methods your sandbox policy exposes to them.
- Keep the sandbox policy as narrow as you can, whatever the version.
Why it matters
The classes are CWE-693, protection mechanism failure, and CWE-863, incorrect authorization. The sandbox already checked string conversion inside arrays but stopped at Traversable objects, whose contents are only read later by functions that convert them to strings. The in operator falls back to a PHP comparison that also converts objects to strings.
The advisory adds a point worth remembering: the in operator can act as a content oracle. Each comparison leaks one bit about the string, and chained comparisons could rebuild a value even when every method is denied. So a bypass can leak data without direct output. The record does not mark this CVE as exploited, and it is not on the CISA Known Exploited Vulnerabilities list.
Paste your lockfile or manifest into the free in-browser dependency scan to see whether twig/twig is in your tree, including as a transitive dependency. Reachability analysis can then show whether your code calls the affected path, which helps you order the work.
Quick check
What is a content oracle?
A feature that answers yes or no questions about hidden data. Enough answers can reveal the data.
Sources
Last reviewed: 19 October 2026.