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



GHSA-957R-QF9P-67XW

GHSA-957R-QF9P-67XW: Arbitrary File Read via SplFileObject in Craft CMS Twig Extension

Alon Barad
Alon Barad
Software Engineer

Aug 6, 2026·6 min read·17 visits

Executive Summary (TL;DR)

Craft CMS administrators with template capabilities can read sensitive server files (such as .env and system configurations) by abusing an omission in the dynamic class helper's blocklist to instantiate PHP's SplFileObject.

An information disclosure vulnerability in Craft CMS allows users with administrative or non-sandboxed template-authoring privileges to read arbitrary system and configuration files. The issue stems from an incomplete class instantiation blocklist in the Twig template extension, which omitted PHP's built-in SplFileObject class.

Vulnerability Overview

Craft CMS is a content management system built on PHP and the Twig template engine. To facilitate dynamic operations, the platform implements custom Twig extensions that expose utility helper functions directly inside template environments. One such helper is the create() function, designed to allow template authors to instantiate arbitrary utility classes within the Twig environment.

While this feature is intended to increase template flexibility, it introduces a significant attack surface by exposing direct object instantiation capabilities to template authors. To prevent abuse, such as remote command execution or file system manipulation, the helper relies on an explicit blocklist of forbidden classes. However, if a dangerous class is omitted from this blocklist, any user capable of writing or modifying non-sandboxed templates can instantiate that class and interact with its methods.

This specific vulnerability is classified under CWE-470 (Use of Externally-Controlled Input to Select Classes or Code, or 'Unsafe Reflection'). Because the class dynamic creation mechanism did not fully restrict access to file-handling classes, it allowed authenticated users with template-authoring permissions to read arbitrary local files, including confidential configuration keys, via standard PHP object manipulation interfaces.

Root Cause Analysis

The underlying vulnerability is located within the createFunction() method inside the custom Twig extension class (src/web/twig/Extension.php). This method accepts a class name identifier as a string and an optional array of parameters, which are then used to dynamically instantiate the specified object using reflection or standard PHP instantiation routines.

To restrict the instantiation of dangerous classes, the method utilizes a blocklist array containing classes known to pose security risks. The original implementation of this blocklist included Symfony\Component\Process\Process (to prevent command injection), GuzzleHttp\Psr7\FnStream (to prevent stream abuse), and SimpleXMLElement (to prevent XML External Entity injection). However, it failed to block SplFileObject, which is a built-in PHP class representing a local file stream.

Because SplFileObject implements PHP's SeekableIterator, RecursiveIterator, and IteratorAggregate interfaces, it behaves as an iterable collection of file lines. When an attacker passes SplFileObject as the target class to the create() helper, the PHP interpreter instantiates the object and opens a read stream to the file path provided in the parameters. This allows the template engine to bypass standard path restrictions and access files directly on the host system.

Code-Level Diff & Patch Analysis

The vulnerability was mitigated by adding SplFileObject directly to the class blocklist within src/web/twig/Extension.php across both the 4.x and 5.x maintenance branches. This prevents the dynamic instantiation helper from processing any request to create an instance of this file-handling class.

Below is the code-level change applied in the 5.x branch to restrict the instantiation of SplFileObject:

File: src/web/twig/Extension.php
@@ -73,6 +73,7 @@
 use IteratorAggregate;
 use Money\Money;
 use SimpleXMLElement;
+use SplFileObject;
 use Symfony\Component\Process\Process;
 use Throwable;
 use Traversable;
@@ -1552,6 +1553,7 @@ public function createFunction(string|array $type, array $params = []): object
             FnStream::class,
             Process::class,
             SimpleXMLElement::class,
+            SplFileObject::class,
         ];
 
         foreach ($blocklist as $c) {

While this change successfully blocks SplFileObject, a blocklist-based approach remains structurally fragile compared to an allowlist. Third-party packages loaded via Composer into the vendor/ directory could introduce other classes that permit arbitrary file reading, server-side request forgery (SSRF), or deserialization. A robust remediation strategy would deprecate arbitrary dynamic class instantiation in template contexts entirely, or enforce a strict, closed allowlist of permitted utility classes.

Exploitation Methodology

To exploit this vulnerability, an attacker must first obtain credentials for an account with permissions to author or edit Twig templates that are evaluated in a non-sandboxed context. This access is typically restricted to administrators or highly privileged content managers who configure system templates, custom fields, or entry-type rendering options within the Craft CMS Control Panel.

Once the template-authoring interface is accessible, the attacker can inject a payload that leverages the create() helper. By specifying the string 'SplFileObject' as the first argument and an array containing the path to a sensitive local file as the second argument, the attacker forces the server to open the target file. The attacker then uses a standard Twig iteration loop ({% for %}) to read each line sequentially and render it to the output page.

The following Twig code snippet demonstrates a functional proof-of-concept payload designed to extract the database configurations and system security keys contained in the local environment file:

{# Craft CMS SplFileObject Arbitrary File Read PoC #}
{% set file = create('SplFileObject', ['.env']) %}
{% for line in file %}
    {{ line }}
{% endfor %}

Impact & Threat Assessment

The concrete security impact of this vulnerability is significant, as it permits unauthorized access to the application's environment configuration file (.env). The .env file in Craft CMS contains the primary database credentials, third-party API integration keys, SMTP server credentials, and the global application security key (CRAFT_SECURITY_KEY).

Acquiring the CRAFT_SECURITY_KEY represents a high-severity threat. The application uses this key to sign cookies, generate secure tokens, and encrypt serialized data. If an attacker recovers this key, they can craft valid cryptographic signatures to perform object deserialization attacks or forge administrative sessions, potentially escalating the initial information disclosure vulnerability into a remote code execution vector.

Additionally, on host operating systems where PHP file permissions are weak, this vulnerability can be leveraged to read sensitive system configuration files outside the web directory. For example, on standard Linux installations, an attacker could read /etc/passwd to enumerate local system users and facilitate targeted privilege escalation attacks.

Defensive Strategies & Remediation

The primary remediation for this vulnerability is to upgrade Craft CMS to a patched release. Organizations running the 4.x release line must update to version 4.18.2 or later. Organizations running the 5.x release line must update to version 5.10.6 or later. These updates modify the createFunction() blocklist to prevent the instantiation of SplFileObject and other related file system stream classes.

If patching cannot be executed immediately, administrators should implement defensive configuration controls. Restricting the PHP execution environment using the open_basedir directive in php.ini can limit the directories that PHP's file system classes are permitted to open. This prevents SplFileObject from accessing files outside of designated application paths, even if the blocklist bypass is exploited.

Furthermore, administrative template-authoring capabilities should be strictly restricted to trusted staff members. Organizations should regularly review user permissions to ensure that only authorized developers are granted access to write or modify custom Twig templates, thereby reducing the exposure of non-sandboxed template evaluation interfaces.

Official Patches

CraftCMSCraft CMS 4.18.2 Release Tag containing the security patch
CraftCMSCraft CMS 5.10.6 Release Tag containing the security patch

Fix Analysis (2)

Technical Appendix

CVSS Score
4.9/ 10

Affected Systems

Craft CMS 4.xCraft CMS 5.x

Affected Versions Detail

Product
Affected Versions
Fixed Version
Craft CMS
CraftCMS
>= 4.0.0, < 4.18.24.18.2
Craft CMS
CraftCMS
>= 5.0.0, < 5.10.65.10.6
AttributeDetail
CWE IDCWE-470
Attack VectorNetwork / Authenticated Administrative User
Vulnerability ClassUnsafe Reflection
CVSS Score4.9
Exploit Statuspoc
KEV Statusnot listed

MITRE ATT&CK Mapping

T1059.006Command and Scripting Interpreter: Astro/Twig/etc. (Template Engines)
Execution
T1552Unsecured Credentials
Credential Access
T1083File and Directory Discovery
Discovery
CWE-470
Use of Externally-Controlled Input to Select Classes or Code ('Unsafe Reflection')

The application uses externally-controlled input to select a class or code to instantiate, without sufficiently restricting which classes can be instantiated.

Known Exploits & Detection

GitHub Advisory DatabaseProof of concept using standard Twig iteration to leak the server .env file.

References & Sources

  • [1]GitHub Advisory: Craft CMS Arbitrary File Read
  • [2]Fix Commit (5.x Branch)
  • [3]Fix Commit (4.x Branch)

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

•1 day ago•CVE-2026-58254
6.5

CVE-2026-58254: Authorization Bypass in NATS Server Message Tracing for Leaf Node Connections

NATS Server prior to versions 2.12.8 and 2.14.3 contains an incorrect authorization vulnerability (CWE-863) in its message tracing subsystem. When evaluating whether a connection is permitted to publish trace events to a destination subject specified in the Nats-Trace-Dest header, the server only checks standard client permissions and omits permission checks for leaf node connections. This allows a connected leaf node operator with restricted publishing privileges to emit internal trace events to unauthorized subjects and suppress standard message delivery using the Nats-Trace-Only header.

Alon Barad
Alon Barad
8 views•10 min read
•1 day ago•CVE-2026-63341
7.5

CVE-2026-63341: Unauthenticated Denial of Service via Unbounded Topic Depth in Aedes MQTT Broker

CVE-2026-63341 is a high-severity Denial of Service (DoS) vulnerability in the Aedes MQTT broker for Node.js affecting all versions prior to 1.1.1. The flaw stems from missing input validation on the hierarchical depth of incoming MQTT topic strings before they are passed to the underlying topic-matching engine, qlobber. Because qlobber enforces a hardcoded limit of 100 topic levels and throws a synchronous exception when this threshold is exceeded, an attacker can send a single MQTT packet containing 101 or more forward-slash-separated levels to trigger an uncaught exception that immediately terminates the Node.js broker process.

Alon Barad
Alon Barad
14 views•12 min read
•1 day ago•CVE-2026-61725
6.1

CVE-2026-61725: Path Traversal and Arbitrary File Overwrite in sevenz-rust2

CVE-2026-61725 is a path traversal vulnerability (CWE-22) in the sevenz-rust2 Cargo package prior to version 0.21.1. The vulnerability occurs because the decompression utility fails to validate or sanitize archive entry filenames before joining them with the destination directory path via std::path::Path::join. An attacker who supplies a crafted 7z archive containing parent directory traversal sequences or absolute paths can write or overwrite arbitrary files on the host filesystem with the privileges of the extracting process.

Alon Barad
Alon Barad
6 views•12 min read
•1 day ago•CVE-2026-77309
8.8

CVE-2026-77309: Unauthenticated Remote Code Execution in NASA-AMMOS AIT-GUI via Incomplete File Cleanup and Path Traversal

CVE-2026-77309 (GHSA-jrjx-9jjw-747m) is a high-severity unauthenticated remote code execution vulnerability affecting NASA-AMMOS AIT-GUI versions 1.0.0 through 2.5.0. The flaw results from chaining an incomplete file cleanup error in the telemetry query endpoint (/tlm/query) with a directory traversal flaw in the script execution endpoint (/script/run). An attacker on an adjacent network can stage arbitrary Python statements into a static file on disk and execute that file under the privileges of the AIT-GUI web server process.

Amit Schendel
Amit Schendel
13 views•10 min read
•1 day ago•CVE-2026-77332
2.3

CVE-2026-77332: Surfaced-Memory Envelope Injection and Stored Prompt Injection in memtomem-stm

A vulnerability classified under CWE-116 (Improper Encoding or Escaping of Output) exists in memtomem-stm versions 0.1.0 through 0.1.33. The software acts as a Model Context Protocol (MCP) short-term memory proxy gateway for AI agent architectures. When surfacing retrieved memories and scratchpad items into downstream Large Language Model (LLM) context envelopes, the SurfacingFormatter component fails to properly sanitize untrusted memory attributes. An attacker with the ability to plant untrusted content into the agent's long-term or working memory store can inject arbitrary structural delimiters, close the <surfaced-memories> XML boundary prematurely, visually obscure instructions using Unicode bidirectional overrides, and execute stored prompt injection attacks against downstream LLM agents.

Alon Barad
Alon Barad
15 views•10 min read
•2 days ago•CVE-2026-77331
2.0

CVE-2026-77331: Race Condition and Session State Corruption in memtomem-stm

CVE-2026-77331 (GHSA-72jh-722p-rqr3) is a concurrency and session-state synchronization vulnerability in memtomem-stm, a short-term memory proxy gateway for AI agents. In versions 0.1.2 prior to 0.1.34, concurrent Model Context Protocol (MCP) Remote Procedure Call (RPC) failures or mid-flight task cancellations can initiate duplicate reconnect loops and permit dirty or cancelled transport sessions to be reused. This deficiency results in session-state integrity loss and local service degradation.

Amit Schendel
Amit Schendel
8 views•9 min read