CVEReports
CVEReports

Automated vulnerability intelligence platform. Comprehensive reports for high-severity CVEs generated by AI.

Product

  • Home
  • Sitemap
  • RSS Feed

Company

  • About
  • Contact
  • Privacy Policy
  • Terms of Service

© 2026 CVEReports. All rights reserved.

Made with love by Amit Schendel & Alon Barad



CVE-2026-24425

CVE-2026-24425: Remote Code Execution via Sandbox Bypass in Twig Template Engine

Alon Barad
Alon Barad
Software Engineer

Jun 5, 2026·6 min read·144 visits

Executive Summary (TL;DR)

A dynamic sandbox bypass in Twig (CVE-2026-24425) allows remote code execution because runtime checks fail to propagate the active template's source context to filters like map or sort, allowing arbitrary PHP callables to run.

CVE-2026-24425 is a high-severity sandbox bypass vulnerability in the Twig template engine (affecting versions 2.16.x and 3.9.0 through 3.25.x). The flaw arises when dynamic sandboxing is enabled via a SourcePolicyInterface. During runtime checks of callback-accepting filters (such as map, sort, filter, and reduce), Twig queries the global sandbox status instead of the active template's context. This mismatch allows template authors to pass arbitrary PHP string callables to executive functions, resulting in unauthenticated or low-privilege Remote Code Execution (RCE) on the host.

Vulnerability Overview

The Twig template engine, widely used within the Symfony framework and modern PHP ecosystems, includes an optional sandbox mode designed to compile and execute untrusted templates securely. Many production deployments configure dynamic sandboxing using a SourcePolicyInterface. This interface evaluates whether a template must be sandboxed on a per-template basis, separating trusted system layouts from untrusted user-authored templates.

The attack surface is found in multi-tenant web applications, Content Management Systems (CMS), and software-as-a-service (SaaS) environments where untrusted users can submit custom template layouts. Because dynamic templates are marked sandboxed via the policy rather than a global switch, the execution engine must trace and apply isolation policies dynamically across all active contexts.

The vulnerability, identified as CVE-2026-24425, is a protection mechanism failure (CWE-693). When a sandbox is evaluated dynamically, the runtime validation engine fails to propagate the template's source context to specific array filter callback validations. This failure allows standard template authors to execute arbitrary PHP functions outside the sandbox environment.

Root Cause Analysis

To prevent remote code execution, Twig strictly limits the callback parameters allowed inside native template filters such as sort, filter, map, reduce, and find. Inside a sandbox environment, these filters must only accept PHP Closure objects (anonymous functions and short arrows) rather than arbitrary string callables. This prevention mechanism is governed by the checkArrow routine within the CoreExtension module.

public static function checkArrow(Environment $env, $arrow, $thing, $type)
{
    if ($arrow instanceof \Closure) {
        return;
    }
 
    if ($env->hasExtension(SandboxExtension::class) && $env->getExtension(SandboxExtension::class)->isSandboxed()) {
        throw new RuntimeError(\sprintf('The callable passed to the "%s" %s must be a Closure in sandbox mode.', $thing, $type));
    }
}

The vulnerability exists because isSandboxed() is invoked without arguments. Calling isSandboxed() on the SandboxExtension without passing a specific template Source object queries the global sandbox state, which returns false under dynamic policy-based sandboxing.

Consequently, the validation check passes silently because the execution environment believes no sandbox is active. The engine then passes the unrestricted string callable directly to the underlying PHP runtime functions (such as uasort or array_map), leading to raw system execution.

Code Analysis and Comparison

The patch addresses the context propagation failure by modifying how the compiler and the extension filters access sandbox state. Filters now request the sandboxed state explicitly by utilizing the needs_is_sandboxed attribute.

In the patched version of src/Extension/CoreExtension.php, the core callback-accepting filters are updated to receive the template's active sandbox status as a boolean argument.

@@ -263,14 +263,14 @@ public function getFilters(): array
             new TwigFilter('join', [self::class, 'join']),
             new TwigFilter('split', [self::class, 'split'], ['needs_charset' => true]),
-            new TwigFilter('sort', [self::class, 'sort'], ['needs_environment' => true]),
+            new TwigFilter('sort', [self::class, 'sort'], ['needs_environment' => true, 'needs_is_sandboxed' => true]),
             new TwigFilter('merge', [self::class, 'merge']),
             new TwigFilter('batch', [self::class, 'batch']),
             new TwigFilter('column', [self::class, 'column']),
-            new TwigFilter('filter', [self::class, 'filter'], ['needs_environment' => true]),
-            new TwigFilter('map', [self::class, 'map'], ['needs_environment' => true]),
-            new TwigFilter('reduce', [self::class, 'reduce'], ['needs_environment' => true]),
-            new TwigFilter('find', [self::class, 'find'], ['needs_environment' => true]),
+            new TwigFilter('filter', [self::class, 'filter'], ['needs_environment' => true, 'needs_is_sandboxed' => true]),
+            new TwigFilter('map', [self::class, 'map'], ['needs_environment' => true, 'needs_is_sandboxed' => true]),
+            new TwigFilter('reduce', [self::class, 'reduce'], ['needs_environment' => true, 'needs_is_sandboxed' => true]),
+            new TwigFilter('find', [self::class, 'find'], ['needs_environment' => true, 'needs_is_sandboxed' => true]),

The internal helper function signature drops its dependency on the Environment object, checking the newly supplied boolean directly.

@@ -2091,13 +2091,13 @@ public static function arrayEvery(Environment $env, $array, $arrow)
-    public static function checkArrow(Environment $env, $arrow, $thing, $type)
+    public static function checkArrow(bool $isSandboxed, $arrow, $thing, $type)
     {
         if ($arrow instanceof \Closure) {
             return;
         }
 
-        if ($env->hasExtension(SandboxExtension::class) && $env->getExtension(SandboxExtension::class)->isSandboxed()) {
+        if ($isSandboxed) {
             throw new RuntimeError(\sprintf('The callable passed to the "%s" %s must be a Closure in sandbox mode.', $thing, $type));
         }

Additionally, legacy compiler pathways recover the calling template's context dynamically by walking the PHP stack trace. The twig_resolve_caller_source routine inspects the trace to ensure the sandbox configuration is robustly recovered and applied.

Exploit Methodology

To exploit this vulnerability, an attacker must have privileges to author, upload, or modify a Twig template rendered under a dynamic SourcePolicyInterface sandbox configuration.

The attacker crafts a template payload containing a callback-accepting filter, such as map, sort, filter, or reduce. Instead of providing a secure anonymous function, the attacker passes a sensitive system callable string (e.g., 'system', 'passthru', 'shell_exec').

{# Attack vector using the map filter to invoke system execution #}
{{ ["id"]|map("system")|join }}

During rendering, the compiler processes this block into PHP. Since the sandbox check is bypassed, the application maps the array containing the command argument ("id") directly to the PHP system() command. The host server executes the command and injects the output of the process into the rendered template context returned to the attacker.

Impact Assessment

The impact of CVE-2026-24425 is rated high (CVSS 8.8) because it leads directly to Remote Code Execution on the application server. Any host that accepts dynamically sandboxed templates from external users can be completely compromised by an attacker with standard template authoring permissions.

Successful execution grants shell access under the privileges of the web application user (e.g., www-data). Attackers can perform local file read operations, access database configuration strings, write web shells to public directories, or attempt local privilege escalation within containerized hosts.

Because the vulnerability bypasses Twig's sandboxing architecture, it undermines the security assumption of template isolation. Applications that rely on dynamic templates for multi-tenant customer dashboards or dynamic newsletter designs are highly susceptible to data leakage and host compromise.

Mitigation and Remediation Guidance

The primary remediation strategy is upgrading the twig/twig dependency to a secure version. Organizations should audit their dependencies and apply the patch as soon as possible.

composer update twig/twig

If upgrading immediately is not feasible, developers should replace the dynamic SourcePolicyInterface dynamic sandbox architecture with a globally enabled sandbox. Global sandboxing is unaffected by this flaw because the global check evaluates to true, triggering the exception block on non-closure callbacks.

// Global configuration workaround
$policy = new \Twig\Sandbox\SecurityPolicy($allowedTags, $allowedFilters, $allowedMethods, $allowedProperties, $functions);
$sandbox = new \Twig\Extension\SandboxExtension($policy, true); // True enforces global isolation
$twig->addExtension($sandbox);

Furthermore, web application firewalls (WAF) can be configured to filter template input blocks containing array filters combined with string constants. Implement standard security scanning to flag Twig templates containing patterns such as |map(, |sort(, or |filter( followed directly by a single or double-quoted string literal.

Official Patches

twigphpCore Extension and Compiler Dynamic Sandbox Patch

Fix Analysis (1)

Technical Appendix

CVSS Score
8.8/ 10
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
EPSS Probability
0.11%
Top 70% most exploited

Affected Systems

Twig PHP template engine within multi-tenant frameworksSymfony installations utilizing dynamic template sandboxing configurationsCMS frameworks executing dynamic custom templates using SourcePolicyInterface

Affected Versions Detail

Product
Affected Versions
Fixed Version
Twig
twigphp
>= 2.16.0, <= 2.16.1N/A
Twig
twigphp
>= 3.9.0, <= 3.25.13.26.0
AttributeDetail
CWE IDCWE-693
Attack VectorNetwork
CVSS v3.18.8
EPSS Score0.00114
Exploit StatusProof-of-Concept
CISA KEV StatusNo

MITRE ATT&CK Mapping

T1562Impair Defenses
Defense Evasion
T1059Command and Scripting Interpreter
Execution
T1203Exploitation for Client Execution / Server Execution
Execution
CWE-693
Protection Mechanism Failure

The product does not use or incorrectly implements a protection mechanism, allowing attackers to bypass security restrictions.

Known Exploits & Detection

GitHubTwig sandbox bypass details and vulnerability POC tests within advisory

Vulnerability Timeline

Vendor publishes fix on public branch
2026-05-19
CVE-2026-24425 and GHSA-2q52-x2ff-qgfr disclosed
2026-05-20
NVD evaluation finalized
2026-06-02

References & Sources

  • [1]Twig Security Advisory (GHSA-2q52-x2ff-qgfr)
  • [2]Twig v3.26.0 Changelog and Official Release Notes
  • [3]CVE Official Record for CVE-2026-24425

Attack Flow Diagram

Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.
Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.

More Reports

•2 days ago•CVE-2026-16454
4.3

CVE-2026-16454: Object-Level Authorization Bypass in Eclipse hawkBit Direct Device Integration Controller

CVE-2026-16454 is an object-level authorization bypass vulnerability (CWE-284, CWE-862) in Eclipse hawkBit versions 1.0.3 and prior. The flaw exists within the Direct Device Integration (DDI) REST controller (hawkbit-ddi-resource), where endpoints responsible for enumerating software module metadata and serving firmware binaries fail to verify whether the requested software module is assigned to the authenticated device. Consequently, any device with valid credentials (such as a TargetToken or GatewayToken) can enumerate software module identifiers and download arbitrary firmware artifacts across the entire tenant namespace.

Amit Schendel
Amit Schendel
11 views•9 min read
•2 days ago•CVE-2026-62284
8.6

CVE-2026-62284: Remote Code Execution and SSRF via Unsanitized Kubeconfig in OSAC Operator

CVE-2026-62284 (GHSA-5w5g-j6hw-6p8f) is a code injection and server-side request forgery vulnerability in the console-proxy component of the OSAC Operator. The RemoteConfigResolver parses Kubernetes Secrets containing kubeconfig files via clientcmd.RESTConfigFromKubeConfig without sanitizing execution-related fields. An attacker with RBAC permissions to create or modify labeled Secrets in monitored namespaces can supply a malicious exec credential plugin, resulting in arbitrary command execution within the console-proxy pod.

Amit Schendel
Amit Schendel
8 views•8 min read
•2 days ago•CVE-2026-62361
5.5

CVE-2026-62361: Authenticated SQL Injection and Table Access Control Bypass in Listmonk Subscriber Export

CVE-2026-62361 (GHSA-xgjr-7j9q-2h4r) is an authenticated SQL injection and authorization bypass vulnerability in listmonk, an open-source, self-hosted newsletter and mailing list manager written in Go. In versions prior to 6.2.0, the subscriber export endpoint (GET /api/subscribers/export) directly interpolates user-supplied SQL filter expressions into a PostgreSQL query without invoking the table allowlist validation function (validateQueryTables). Consequently, authenticated users possessing the subscribers:sql_query and subscribers:get_all permissions can bypass relational access controls, execute arbitrary subqueries against restricted tables such as users and settings, and modify database state via writable Common Table Expressions (CTEs).

Alon Barad
Alon Barad
10 views•11 min read
•2 days ago•CVE-2026-28385
5.0

CVE-2026-28385: Server-Side Request Forgery in Canonical LXD Image Import

CVE-2026-28385 (GHSA-3gq2-x4qg-p4g6) is a Server-Side Request Forgery (SSRF) vulnerability in Canonical LXD versions 4.12 through 6.9. An authenticated user possessing the can_create_images entitlement can force the LXD daemon to execute arbitrary outbound HTTP and HTTPS requests via the /1.0/images API endpoint. Due to the absence of egress destination validation, an attacker can probe host loopback services, RFC 1918 private network segments, and cloud Instance Metadata Services (IMDS) from the network position of the privileged LXD daemon.

Amit Schendel
Amit Schendel
10 views•9 min read
•2 days ago•GHSA-9J25-MM2H-2F76
9.9

CVE-2026-48750: Arbitrary File Write on Host via exec-output Symlink in Canonical LXD and Incus

Canonical LXD and LXC Incus contain an arbitrary file write vulnerability (CWE-73 / CWE-59) in the `/1.0/instances/<name>/exec` REST API endpoint. When an instance is unpacked from an image archive, top-level symbolic links are extracted directly onto the host filesystem within the instance storage directory. If a crafted image includes a symbolic link named `exec-output` pointing to an arbitrary host path, invoking the execution endpoint with `record-output: true` causes the privileged host daemon to follow the symlink and write command output files directly to the target host directory. An authenticated attacker with permissions to import images and execute commands can exploit this flaw to write controlled content to sensitive host directories such as `/etc/cron.d`, resulting in arbitrary code execution on the host as `root`.

Alon Barad
Alon Barad
8 views•12 min read
•2 days ago•GHSA-VGHH-5RFX-XHQ8
9.9

CVE-2026-48749: Arbitrary Host File Read and Write via Malicious Image Symlink in Canonical LXD and Incus

CVE-2026-48749 (tracked as GHSA-vghh-5rfx-xhq8 for LXD and GHSA-2q3f-q5pq-g8wv for Incus) is a critical container escape vulnerability in the Canonical LXD and Linux Containers Incus system container managers. By importing a specially crafted container image archive containing duplicate tar member headers, an authenticated attacker can replace the instance rootfs directory with a symbolic link pointing to the underlying host root filesystem. When performing file operations on a stopped container, the privileged forkfile helper binary resolves the symbolic link without confinement and chroots directly into the host filesystem, granting arbitrary root-level file read and write access.

Amit Schendel
Amit Schendel
8 views•9 min read