CVE-2026-48805: Twig: Sandbox state regression in deprecated internal wrappers in `src/Resources/core.php`
Description
The 3.26.0 source-policy hardening changed the signature of CoreExtension::checkArrow() to take a boolean $isSandboxed instead of an Environment, and added the same $isSandboxed argument to CoreExtension::arraySome() and CoreExtension::arrayEvery(). Compiled templates were updated to pass the per-source sandbox state computed at the call site.
The deprecated internal wrappers exposed in src/Resources/core.php for legacy third-party code (twigcheckarrowinsandbox(), twigarraysome(), twigarrayevery()) were not updated:
- twigarraysome() and twigarrayevery() call CoreExtension::arraySome() / arrayEvery() without forwarding the sandbox state. The underlying methods default $isSandboxed to false, so the callable-must-be-a-Closure restriction is silently bypassed in sandbox mode and a string callable such as 'strcmp' is accepted. - twigcheckarrowinsandbox() passes the Environment object where CoreExtension::checkArrow() now expects a bool, which throws a TypeError on PHP 8+.
Compiled Twig templates are not affected: they call CoreExtension:: directly with the correct arguments. Applications are only impacted if they still call the deprecated twig helpers on top of a sandboxed Environment.
Resolution
The three wrappers now resolve the current sandbox state via twigresolveissandboxed() (the same helper compiled templates use), and forward it to the corresponding CoreExtension:: method. twigcheckarrowinsandbox() no longer triggers a TypeError, and twigarraysome() / twigarrayevery() now enforce the same sandbox restriction as compiled templates.
Credits
We would like to thank El Kharoubi Iosif for reporting the issue and Fabien Potencier for providing the fix.
Other sources
Twig is a template language for PHP. Prior to 3.27.0, deprecated internal wrappers in src/Resources/core.php do not forward the current sandbox state to CoreExtension::checkArrow(), arraySome(), and arrayEvery(), allowing legacy calls such as twigarraysome(), twigarrayevery(), and twigcheckarrowinsandbox() to bypass sandbox callable restrictions. This issue is fixed in version 3.27.0.
— MITRE
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
composer/twig/twigto a version that resolves this vulnerability.Fixed in 3.27.0 - Upgrade
Upgrade
twigto a version that resolves this vulnerability.Fixed in 3.27.0Patch 3.27.0 - Compensating control
If applications still call the deprecated Twig `twig_*` helpers on top of a sandboxed `Environment`, update them to avoid relying on legacy wrappers until Twig is upgraded to 3.27.0 (affected helpers: `twig_check_arrow_in_sandbox()`, `twig_array_some()`, `twig_array_every()`).
Event History
Frequently Asked Questions
What is the severity of CVE-2026-48805?
CVE-2026-48805 has been assessed with a risk rating of 34.
How do I fix CVE-2026-48805?
To fix CVE-2026-48805, upgrade to Twig version 3.27.0 or later.
What components are affected by CVE-2026-48805?
CVE-2026-48805 affects the composer/twig/twig package in version 3.26.0.
What changes were made in Twig related to CVE-2026-48805?
CVE-2026-48805 changed the signature of CoreExtension::checkArrow(), adding a boolean argument to it.
Is CVE-2026-48805 a significant vulnerability?
Yes, CVE-2026-48805 involves alterations to core functions which may pose security risks if not addressed.