Skip to main content

Twig CVE-2026-48805

MEDIUM
Protection Mechanism Failure (CWE-693)
2026-06-30 https://github.com/twigphp/Twig GHSA-p42q-9prx-q5wq
5.3
CVSS 4.0 · Vendor: https://github.com/twigphp/Twig
Share

Severity by source

Vendor (https://github.com/twigphp/Twig) PRIMARY
5.3 MEDIUM
CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:N/VI:L/VA:N/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X
vuln.today AI
8.5 HIGH

AC:H reflects three simultaneous prerequisites (sandbox mode, deprecated wrappers, version 3.26.x); PR:L because template submission typically requires authenticated access; S:C for sandbox escape into the broader PHP process.

3.1 AV:N/AC:H/PR:L/UI:N/S:C/C:H/I:H/A:H
4.0 AV:N/AC:H/AT:P/PR:L/UI:N/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H

Primary rating from Vendor (https://github.com/twigphp/Twig).

CVSS VectorVendor: https://github.com/twigphp/Twig

Attack Vector
Network
Attack Complexity
Low
Privileges Required
Low
User Interaction
None
Scope
X

Lifecycle Timeline

2
CVSS changed
Jul 14, 2026 - 22:22 NVD
5.3 (MEDIUM)
Analysis Generated
Jun 30, 2026 - 19:23 vuln.today

DescriptionCVE.org

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 (twig_check_arrow_in_sandbox(), twig_array_some(), twig_array_every()) were not updated:

  • twig_array_some() and twig_array_every() 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.
  • twig_check_arrow_in_sandbox() 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 twig_resolve_is_sandboxed() (the same helper compiled templates use), and forward it to the corresponding CoreExtension::* method. twig_check_arrow_in_sandbox() no longer triggers a TypeError, and twig_array_some() / twig_array_every() 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.

AnalysisAI

Sandbox bypass in Twig 3.26.x allows string callables to circumvent the Closure-only restriction when applications use the deprecated twig_array_some() and twig_array_every() wrapper functions over a sandboxed Environment. The 3.26.0 source-policy hardening changed CoreExtension::checkArrow() to accept a boolean sandbox state, but the legacy wrappers in src/Resources/core.php were not updated, causing them to silently pass false for $isSandboxed and accept arbitrary string callables such as 'exec' or 'system' that the sandbox was designed to block. No public exploit has been identified at time of analysis, and impact is limited to the narrow subset of applications calling the deprecated wrappers with sandbox mode active.

Technical ContextAI

Twig (pkg:composer/twig_twig) is a PHP template engine with a sandbox mode that restricts callable types - arrow functions must be proper PHP Closure objects, not arbitrary string callables, to prevent template authors from invoking unrestricted PHP functions. The 3.26.0 release introduced a source-policy hardening that refactored CoreExtension::checkArrow() to accept a bool $isSandboxed parameter instead of an Environment object, and added the same parameter to CoreExtension::arraySome() and CoreExtension::arrayEvery(). Compiled templates were updated to call these methods with the correct boolean derived at the call site. However, the three deprecated wrapper functions in src/Resources/core.php - maintained for legacy third-party compatibility - were not updated: twig_array_some() and twig_array_every() call the underlying methods without forwarding sandbox state (defaulting to false), and twig_check_arrow_in_sandbox() passes an Environment object where a bool is now required, triggering a TypeError on PHP 8+. CWE-693 (Protection Mechanism Failure) accurately describes this: the Closure enforcement mechanism exists but fails to engage due to a regression in parameter forwarding through the deprecated code path.

RemediationAI

Upgrade Twig to version 3.27.0 or later, where all three deprecated wrappers have been corrected to resolve sandbox state via twig_resolve_is_sandboxed() and forward it to the corresponding CoreExtension::* methods. The patch is available at https://github.com/twigphp/Twig/releases/tag/v3.27.0; run composer require twig/twig:^3.27.0 to apply the fix. If an immediate upgrade is not possible, audit the codebase and all third-party dependencies for direct calls to twig_check_arrow_in_sandbox(), twig_array_some(), or twig_array_every(), and replace them with their CoreExtension::* equivalents passing the correct boolean sandbox state obtained via twig_resolve_is_sandboxed() - this eliminates the flawed code paths without requiring a package upgrade, though it introduces a maintenance burden and may break third-party packages that cannot be easily patched. As an additional compensating control, if your application does not strictly require Twig sandbox mode with arrow functions or array callbacks, consider auditing whether sandbox mode is actively protecting a real threat model, since disabling sandbox mode entirely removes the bypass but also removes the intended security boundary. Do not rely on disabling sandbox mode as a long-term substitute for patching.

More in PHP

View all
CVE-2019-11043 CRITICAL POC
9.8 Oct 28

In PHP versions 7.1.x below 7.1.33, 7.2.x below 7.2.24 and 7.3.x below 7.3.11 in certain configurations of FPM setup it

CVE-2012-1823 CRITICAL POC
9.8 May 11

sapi/cgi/cgi_main.c in PHP before 5.3.12 and 5.4.x before 5.4.2, when configured as a CGI script (aka php-cgi), does not

CVE-2016-1555 CRITICAL POC
9.8 Apr 21

(1) boardData102.php, (2) boardData103.php, (3) boardDataJP.php, (4) boardDataNA.php, and (5) boardDataWW.php in Netgear

CVE-2018-11138 CRITICAL POC
9.8 May 31

The '/common/download_agent_installer.php' script in the Quest KACE System Management Appliance 8.0.318 is accessible by

CVE-2024-11680 CRITICAL POC
9.8 Nov 26

ProjectSend versions prior to r1720 are affected by an improper authentication vulnerability. Rated critical severity (C

CVE-2025-49113 CRITICAL POC
9.9 Jun 02

Roundcube Webmail contains a critical PHP object deserialization vulnerability (CVE-2025-49113, CVSS 9.9) that allows au

CVE-2017-9841 CRITICAL POC
9.8 Jun 27

Util/PHP/eval-stdin.php in PHPUnit before 4.8.28 and 5.x before 5.6.3 allows remote attackers to execute arbitrary PHP c

CVE-2025-0108 HIGH POC
8.8 Feb 12

Palo Alto Networks PAN-OS management web interface contains an authentication bypass allowing unauthenticated attackers

CVE-2021-25298 HIGH POC
8.8 Feb 15

Nagios XI version xi-5.7.5 is affected by OS command injection. Rated high severity (CVSS 8.8), this vulnerability is re

CVE-2021-25296 HIGH POC
8.8 Feb 15

Nagios XI version xi-5.7.5 is affected by OS command injection. Rated high severity (CVSS 8.8), this vulnerability is re

CVE-2013-4983 CRITICAL POC
10.0 Sep 10

The get_referers function in /opt/ws/bin/sblistpack in Sophos Web Appliance before 3.7.9.1 and 3.8 before 3.8.1.1 allows

CVE-2023-6553 CRITICAL POC
9.8 Dec 15

The Backup Migration plugin for WordPress is vulnerable to Remote Code Execution in all versions up to, and including, 1

Share

CVE-2026-48805 vulnerability details – vuln.today

This site uses cookies essential for authentication and security. No tracking or analytics cookies are used. Privacy Policy