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
View

Attack ChainAIDerived

Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain

  1. Access
    Identify application using deprecated Twig wrappers in sandbox mode
  2. Delivery
    Submit crafted template with string callable argument
  3. Exploit
    Deprecated wrapper passes false sandbox state
  4. Execution
    CoreExtension::arraySome/arrayEvery skips Closure enforcement
  5. Persist
    Arbitrary PHP string callable executes within template context
  6. Impact
    Escape sandbox restrictions

Vulnerability Assessment

Weakness
CWE
OWASP Top 10:2025
A06:2025 - Insecure Design
ASVS 5.0
V15 - Secure Coding and Architecture Protection mechanism completeness
Exploitation Conditions

Exploitation requires all three of the following conditions to be simultaneously true: (1) the application or a dependency it uses calls the deprecated wrapper functions twig_array_some(), twig_array_every(), or twig_check_arrow_in_sandbox() from src/Resources/core.php - compiled Twig templates that call CoreExtension::* methods directly are explicitly not affected; (2) the Twig Environment is configured to run in sandbox mode, as the sandbox restriction on non-Closure callables only applies when sandboxing is active; and (3) the installed Twig version is exactly within the 3.26.x range. Applications on Twig versions prior to 3.26.0 or on 3.27.0 and later are not affected. The TypeError denial-of-service variant of the bug (twig_check_arrow_in_sandbox() receiving an Environment where a bool is expected) is additionally limited to PHP 8+ environments. Exploitation is not possible against applications that have no user-controlled template submission pathway regardless of the above conditions.

Impact

No CVSS vector or EPSS score was provided for this CVE, so quantitative risk ranking cannot be confirmed. The vulnerability is not listed in the CISA KEV catalog and no public exploit code has been identified, both pointing to low active exploitation probability. Real-world risk is further constrained by the intersection of three specific conditions that must all be true simultaneously: Twig version must be exactly 3.26.x, the application must operate Twig in sandbox mode, and the application or a dependency must still invoke the deprecated twig_* wrapper functions rather than compiled templates. The Authentication Bypass tag applied to this CVE somewhat overstates the nature of the flaw - this is a sandbox policy bypass within an already-authenticated or controlled template submission context, not an authentication mechanism bypass. The TypeError impact on PHP 8+ for twig_check_arrow_in_sandbox() could additionally cause availability disruption. Despite the potentially severe consequences of a sandbox escape (arbitrary PHP function execution), the conditional footprint narrows practical risk substantially, placing this in a medium real-world priority tier rather than an emergency response.

Exploit ScenarioDerived

In a multi-tenant CMS or SaaS application where authenticated users can submit Twig templates evaluated in sandbox mode, an attacker submits a template calling array_some or array_every with a string callable such as 'system' or 'file_get_contents'. Because the deprecated wrapper forwards $isSandboxed=false to the underlying method, the Closure restriction is not enforced and the string callable is accepted and executed, allowing the attacker to run arbitrary PHP functions outside the intended sandbox boundary. No public exploit code has been identified at time of analysis.

This Month Plan within 30 days. Why: MEDIUM severity (CVSS 4.0-6.9).
Patch available 0.3% exploitation probability (EPSS)

Get an e-mail when this CVE is exploited, patched or re-scored. Free account.

Alert me

AnalysisAIv1 – Jun 30, 2026

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.

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.

Affected Packages

composer twig/twig fix: 3.27.0

Source: OSV (Open Source Vulnerabilities)

Affects your stack

Affects 1 package in composer

Checking this CVE against your own stacks and servers is part of the Basic plan and up.

Technical ContextAI · show details

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.

Know when PHP gets its next vulnerability

  • Watch products and get an email when something new is published
  • Check this CVE against your own stack and servers
  • Exploit and PoC references, threat intelligence from 22 sources

No credit card · 7-day full trial

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
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
Attack Requirements
None
Privileges Required
Low
User Interaction
None
Vulnerable system: Confidentiality
None
Vulnerable system: Integrity
Low
Vulnerable system: Availability
None
Subsequent system: Confidentiality
None
Subsequent system: Integrity
None
Subsequent system: Availability
None

Lifecycle Timeline

1
CVSS changed
Jul 14, 2026 - 22:22 NVD
5.3 (MEDIUM)

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.

Threat Intelligence Overview

EPSS Score
0.3%
Top 81% exploitable
Prevalence
Medium
popular PHP template engine, dominant in Symfony-based projects
Threat Intel
1
1 source
Social Media
1
Sightings
Data Quality
4 sources
Confidence: Medium

How this decision was reached

The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.

SignalValue
Severity MEDIUM
CISA KEV No
Public POC No
EPSS 0.3%
Patch available Yes
Active threat No
Deciding rule
MEDIUM severity (CVSS 4.0-6.9)
What every action level means
Emergency Immediate action required. Criteria: CRITICAL + in CISA KEV (actively exploited) without patch, OR CRITICAL + EPSS > 30% without patch, OR CRITICAL + active threat signals without patch.
Act Now Prioritize within 24-48h. Criteria: in KEV with patch available, OR CRITICAL + public POC, OR HIGH + EPSS > 10%, OR CRITICAL + active threat, OR any CRITICAL severity.
This Week Schedule remediation this week. Criteria: HIGH severity (CVSS 7.0-8.9). Patch within normal change window.
This Month Plan within 30 days. Criteria: MEDIUM severity (CVSS 4.0-6.9), lower exploitation probability. Include in regular patch cycle.
Monitor Track and reassess. Criteria: LOW severity (CVSS 0.1-3.9), minimal exploitation risk. No immediate action needed.

SSVC AssessmentENISA

SSVC Decision· derived
Scheduled
Exploitation· derived
None
System Exposure· derived
Open
Automatable· derived
No
Human Impact· derived
Medium

Priority Score

26
Low Medium High Critical
KEV: 0
EPSS: 0
CVSS: +26
PoC: 0
Weaponized: 0
Threat intel: 0
Gov advisory: 0

Attack Technique

Authentication bypass attacks exploit flaws in the verification mechanisms that control access to systems and applications.

Affected Products (CPE)CVE.org

pkg:composer/twig_twig

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

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