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-59191

CVE-2026-59191: Path Traversal and Arbitrary File Read in CakePHP TwigView FileLoader

Alon Barad
Alon Barad
Software Engineer

Nov 25, 2026·9 min read·5 visits

Executive Summary (TL;DR)

CakePHP's TwigView plugin (versions < 1.3.3 and >= 2.0.0, < 2.1.2) fails to restrict template resolution paths in FileLoader::findTemplate(), allowing attackers to read arbitrary local files when user input is passed to Twig include tags.

A path traversal vulnerability exists in the cakephp/twig-view plugin for the CakePHP framework prior to versions 1.3.3 and 2.1.2. The Cake\TwigView\Twig\FileLoader::findTemplate() method verifies template existence using PHP's native file_exists() function without ensuring the target path resides within configured application or plugin template directories. When user-controlled input is passed to template inclusion mechanisms, an unauthenticated remote attacker can read arbitrary local files accessible to the PHP runtime.

Vulnerability Overview

The cakephp/twig-view package is an official plugin for the CakePHP framework that integrates the Twig template engine into CakePHP's view rendering layer. It provides wrappers around standard CakePHP View operations, exposes framework helpers, and implements a custom Twig template loader (Cake\TwigView\Twig\FileLoader) to resolve templates across application directories and loaded CakePHP plugins.

In versions prior to 1.3.3 on the 1.x branch and prior to 2.1.2 on the 2.x branch, FileLoader fails to enforce directory boundaries when resolving template paths. The vulnerability is classified under CWE-22 (Improper Limitation of a Pathname to a Restricted Directory). Specifically, the template lookup routine checks whether a requested template string exists directly on the filesystem before attempting relative path resolution within designated template directories.

This behavior exposes an attack surface whenever user-supplied data influences template selection or inclusion. In applications where request parameters or unvalidated variables are passed into Twig template inclusion directives (such as {% include %}) or view rendering methods, an attacker can specify arbitrary filesystem paths. Because the loader immediately accepts any existing file path, the Twig engine loads and renders the contents of local files outside the intended web root or template root.

Root Cause Analysis

The root cause of CVE-2026-59191 resides in the implementation of Cake\TwigView\Twig\FileLoader::findTemplate(string $name): string. This method implements the path resolution contract required by Twig's \Twig\Loader\LoaderInterface. It is responsible for translating logical template names (such as PluginName.Controller/template_name or relative view names) into absolute filesystem paths.

To support internal CakePHP operations—such as rendering view elements where the framework may pass an already-resolved absolute filesystem path into the loader—findTemplate() begins with a fast-path check using PHP's native file_exists($name) function. In the vulnerable implementation, if file_exists($name) returns true, the function immediately returns $name to the caller without any further validation.

This design assumes that any existing file path passed to findTemplate() was previously resolved and validated by trusted framework internals. However, Twig's {% include %} tag, include() function, and {% extends %} tag all invoke findTemplate() directly with whatever string expression is evaluated inside the template. If a developer passes untrusted user input to one of these tags, the attacker controls the $name argument directly.

Because no boundary check validates that $name is prefixed by one of the application's configured template directories (App::path('templates')) or an active plugin's template directory (Plugin::templatePath($pluginName)), any readable file on the host filesystem satisfies the file_exists($name) condition. Furthermore, relative path traversal sequences (e.g., ../../../../etc/passwd) resolved against the current working directory of the PHP process will also pass the file_exists() check and bypass subsequent plugin and extension checks.

Code Analysis & Patch Evaluation

In the vulnerable versions of src/Twig/FileLoader.php, the findTemplate() method performs an unguarded check at the very beginning of execution:

public function findTemplate(string $name): string
{
    // VULNERABLE: Directly returns any existing path on the filesystem
    // without verifying confinement within allowed template directories.
    if (file_exists($name)) {
        return $name;
    }
 
    [$plugin, $name] = pluginSplit($name);
    // ... subsequent plugin and app template path resolution ...
}

The security patch, introduced in commits 1c5107c9f562ab285273ceafd1c28bf314faa6d5 (2.x branch) and 65f5035ee65e76925242fdca2dc2bb0d732b6c1d (1.x branch), modifies findTemplate() to enforce strict prefix validation whenever file_exists($name) evaluates to true:

public function findTemplate(string $name): string
{
    $templatePaths = App::path('templates');
    if (file_exists($name)) {
        // Normalize double slashes to prevent trivial string prefix mismatches
        $name = str_replace('//', '/', $name);
 
        // Verify if the path resides within the application's configured template paths
        foreach ($templatePaths as $templatePath) {
            if (str_starts_with($name, $templatePath)) {
                return $name;
            }
        }
 
        // Verify if the path resides within any loaded plugin's template path
        foreach (Plugin::loaded() as $pluginName) {
            $pluginPath = Plugin::templatePath($pluginName);
            if (str_starts_with($name, $pluginPath)) {
                return $name;
            }
        }
 
        // Reject existing files outside allowed roots with a LoaderError
        throw $this->loaderError($name, $templatePaths);
    }
 
    [$plugin, $name] = pluginSplit($name);
    // ...
}

> [!NOTE] > Fix Completeness Assessment: While the patch prevents arbitrary absolute paths (such as /etc/passwd or /tmp/secret.txt) from bypassing directory checks, it relies on string prefix matching via str_starts_with($name, $templatePath) without first canonicalizing $name using realpath(). If an attacker supplies an existing path that starts with a valid $templatePath prefix followed by ../ traversal segments (for example, /var/www/app/templates/../../../../etc/passwd), file_exists($name) returns true and str_starts_with($name, $templatePath) also evaluates to true. Furthermore, in the fallback loop where $this->checkExtensions($templatePath . $name) is called, appending a relative traversal sequence like ../../../../etc/passwd to $templatePath could still resolve outside the root if the target file shares a valid template extension (such as .twig or .ctp). True confinement requires canonicalizing the candidate path with realpath() before performing the str_starts_with() prefix check.

Exploitation Methodology

Exploiting CVE-2026-59191 requires an application endpoint that passes user-controlled input into a Twig template inclusion context or directly into the view rendering pipeline. A common vulnerable pattern occurs when an application dynamically selects a partial template or layout element based on a query parameter or request attribute:

{# Vulnerable Twig template: template_path_restriction.twig #}
<div class="dynamic-content">
    {% include item %}
</div>

When the controller assigns unvalidated request data to the item view variable (e.g., $this->set('item', $this->request->getQuery('section'));), the attacker can supply an arbitrary filesystem path in the HTTP request:

GET /pages/display?section=/etc/passwd HTTP/1.1
Host: vulnerable-cakephp-app.example.com

During template rendering, Twig processes the {% include item %} tag and passes /etc/passwd to FileLoader::findTemplate('/etc/passwd'). The file_exists('/etc/passwd') check succeeds and returns /etc/passwd. Twig then reads the file contents, compiles it as a Twig template, and outputs the rendered result inside the HTTP response.

The unit test added by the maintainers in tests/TestCase/View/TwigViewTest.php demonstrates the exact trigger mechanism used to verify the flaw:

public function testTemplatePathRestriction(): void
{
    $path = TMP . 'secret.txt';
    file_put_contents($path, 'SECRET DATA from /tmp/secret.txt');
    $view = new AppView();
    $view->set('item', $path);
    $this->expectException(LoaderError::class);
    $this->expectExceptionMessage('Could not find template');
    $view->render('template_path_restriction');
}

One operational constraint during exploitation is that Twig attempts to lex and parse the target file as a Twig template. Plaintext files, configuration files (such as .env, /etc/passwd, or INI files), and source code files that do not contain syntactic constructs conflicting with Twig delimiters ({{, {%, {#) will render cleanly into the response output. Files containing raw syntax that collides with Twig's lexer may trigger a \Twig\Error\SyntaxError, though partial content or error messages may still leak sensitive data if debug mode is enabled.

Impact Assessment

The primary impact of CVE-2026-59191 is unauthorized disclosure of local files accessible to the user account running the PHP web server or PHP-FPM worker process. Attackers can leverage this capability to read application configuration files (such as config/app_local.php or .env), exposing database credentials, API keys, encryption salts (Security.salt), and session configuration secrets.

Under CVSS v4.0, this vulnerability is assigned a base score of 6.9 (Medium) with the vector CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:L/VI:N/VA:N/SC:N/SI:N/SA:N. The attack vector is Network (AV:N), with Low attack complexity (AC:L), no special attack requirements (AT:N), no required privileges (PR:N), and no user interaction (UI:N). Confidentiality impact on the vulnerable system is rated Low (VC:L) in the standard advisory baseline, though in practice, reading config/app_local.php in a CakePHP environment frequently leads to broader compromise by exposing cryptographic secrets or database access.

If an attacker extracts the CakePHP Security.salt value via arbitrary file read, they may be able to forge signed cookies, tamper with CSRF tokens, or exploit deserialization gadgets if signed payloads are trusted by the application. Additionally, reading /proc/self/environ or /proc/self/cmdline on Linux hosts can disclose environment variables injected into containerized deployments.

Threat intelligence metrics indicate a low current probability of mass automated exploitation. The Exploit Prediction Scoring System (EPSS) assigns CVE-2026-59191 a score of 0.00477 (0.48%, 41.73rd percentile). The vulnerability is not listed in the CISA Known Exploited Vulnerabilities (KEV) catalog, and no weaponized exploit modules exist in public frameworks because exploitation depends on application-specific template rendering patterns.

Remediation & Mitigation

The definitive remediation is to upgrade cakephp/twig-view to a patched release that enforces template path prefix checks in FileLoader::findTemplate(). Users on the 1.x release branch must upgrade to version 1.3.3 or later, and users on the 2.x release branch must upgrade to version 2.1.2 or later.

To apply the update via Composer, execute the appropriate command for your application's branch:

# For CakePHP TwigView 2.x installations
composer require "cakephp/twig-view:^2.1.2"
 
# For CakePHP TwigView 1.x installations
composer require "cakephp/twig-view:^1.3.3"

In addition to upgrading the package, developers should audit all Twig templates and controller actions to ensure user-supplied input is never passed directly into template resolution tags such as {% include %}, {% extends %}, {% import %}, or include(). If an application requires dynamic template selection based on user input, validate the input against a strict allowlist of known template identifiers before passing it to the view layer.

// Defensive allowlist validation in a CakePHP Controller
$allowedSections = [
    'overview' => 'Elements/overview',
    'details'  => 'Elements/details',
    'summary'  => 'Elements/summary',
];
 
$requested = $this->request->getQuery('section');
if (!is_string($requested) || !isset($allowedSections[$requested])) {
    throw new BadRequestException('Invalid template section requested.');
}
 
$this->set('item', $allowedSections[$requested]);

Given the lack of realpath() canonicalization in the upstream patch, applying strict input validation or prohibiting .. sequences in any variable used near template loading functions provides critical defense-in-depth against path traversal bypasses.

Official Patches

CakePHPGitHub Security Advisory GHSA-hq9r-72jq-2pxp
CakePHPCakePHP TwigView 2.1.2 Release
CakePHPCakePHP TwigView 1.3.3 Release

Fix Analysis (3)

Technical Appendix

CVSS Score
6.9/ 10
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:L/VI:N/VA:N/SC:N/SI:N/SA:N
EPSS Probability
0.48%
Top 58% most exploited

Affected Systems

cakephp/twig-view (1.x branch prior to 1.3.3)cakephp/twig-view (2.x branch prior to 2.1.2)

Affected Versions Detail

Product
Affected Versions
Fixed Version
cakephp/twig-view
CakePHP
< 1.3.31.3.3
cakephp/twig-view
CakePHP
>= 2.0.0, < 2.1.22.1.2
AttributeDetail
Vulnerability TypeCWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
Affected ComponentCake\TwigView\Twig\FileLoader::findTemplate() in cakephp/twig-view
Attack VectorNetwork (Unauthenticated arbitrary file read via user-controlled template inclusion)
CVSS v4.0 Score6.9 Medium (CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:L/VI:N/VA:N/SC:N/SI:N/SA:N)
EPSS Score0.48% (41.73rd Percentile)
Exploit StatusNo known public exploits or active exploitation (Not in CISA KEV)
Patched Versions1.3.3 (1.x branch), 2.1.2 (2.x branch)

MITRE ATT&CK Mapping

T1083File and Directory Discovery
Discovery
T1005Data from Local System
Collection
CWE-22
Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')

The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.

Vulnerability Timeline

Preceding security fix merged bumping minimum Twig version to v3.11
2024-10-11
Patch authored by Mark Story fixing path traversal in FileLoader::findTemplate()
2026-06-19
Fix merged into 2.x branch via Pull Request #118
2026-06-20
Security fixes backported to 1.x branch via Pull Request #120
2026-06-21
CVE-2026-59191 and GitHub Security Advisory GHSA-hq9r-72jq-2pxp published
2026-11-11
NVD record updated with CVSS v4.0 assessment
2026-11-12
OSV database record updated
2026-11-19

References & Sources

  • [1]GitHub Security Advisory GHSA-hq9r-72jq-2pxp
  • [2]NVD - CVE-2026-59191 Detail
  • [3]CVE.org Record: CVE-2026-59191
  • [4]Fix Commit 1c5107c9f562ab285273ceafd1c28bf314faa6d5 (2.x Branch)
  • [5]Fix Commit 65f5035ee65e76925242fdca2dc2bb0d732b6c1d (1.x Branch)
  • [6]CakePHP TwigView Release 2.1.2
  • [7]CakePHP TwigView Release 1.3.3
Related Vulnerabilities
CVE-2024-45411

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

•7 minutes ago•CVE-2026-59726
10.0

CVE-2026-59726: Unauthenticated Remote Code Execution in Ruflo MCP Bridge

Ruflo versions prior to 3.16.3 expose the Model Context Protocol (MCP) bridge HTTP endpoints (`POST /mcp` and `POST /mcp/:group`) on all network interfaces (`0.0.0.0:3001`) without authentication. Because the primary JSON-RPC tool dispatcher (`executeTool()`) bypasses existing tool blocklists, an unauthenticated network attacker can invoke the `terminal_execute` tool to achieve arbitrary command execution inside the bridge container. This initial access permits full exfiltration of third-party LLM provider API keys, unauthorized access to the co-located MongoDB instance, and manipulation of the AgentDB learning store.

Alon Barad
Alon Barad
1 views•2 min read
•about 1 hour ago•CVE-2026-59818
6.5

CVE-2026-59818: Improper Certificate Revocation List (CRL) Validation on Split gRPC Listeners in etcd

In etcd versions prior to 3.5.32 and 3.6.13, configuring the server with --listen-client-http-urls decouples HTTP and gRPC traffic onto distinct network listeners. Due to an implementation flaw in how TLS configurations are passed to the gRPC server instance, the Certificate Revocation List (CRL) defined by --client-crl-file is enforced exclusively on the HTTP listener and omitted entirely on the dedicated gRPC listener. This allows an adversary possessing a revoked, CA-signed client certificate to bypass mutual TLS (mTLS) revocation checks and authenticate directly to the gRPC interface.

Amit Schendel
Amit Schendel
6 views•10 min read
•about 2 hours ago•CVE-2026-59831
4.4

CVE-2026-59831: Remote Code Execution via Unvalidated URL Scheme Handling in GitHub CLI

GitHub CLI (gh) versions 2.10.0 through 2.95.0 contain an input validation vulnerability in the `gh codespace jupyter` command path. When connecting to a remote Codespace to launch a JupyterLab session, the CLI retrieves a server URL via a remote procedure call (RPC) and passes it directly to the host operating system's default URL dispatcher without validating the scheme or target host. A compromised or malicious Codespace can return a custom protocol URI, such as `vscode://` or `vscode-insiders://`, allowing an attacker to invoke local desktop application handlers and achieve arbitrary command execution on the developer's workstation.

Alon Barad
Alon Barad
8 views•9 min read
•about 4 hours ago•CVE-2026-64855
8.2

CVE-2026-64855: Cryptographic Signature Verification Bypass in soapbar WS-Security Implementation

CVE-2026-64855 (GHSA-859w-52fx-hcm6) is a cryptographic signature verification and authentication bypass vulnerability in the soapbar Python library prior to version 0.13.0. In vulnerable versions, the verify_envelope_bsp() function derives its trust anchor directly from the incoming SOAP message by extracting an untrusted X.509 certificate embedded inside the wsse:BinarySecurityToken header. Because the function checks only the temporal validity of the extracted certificate without performing Certificate Authority (CA) chain validation or certificate pinning, an unauthenticated network attacker can generate a self-signed certificate, sign an arbitrary SOAP payload, and pass verification.

Amit Schendel
Amit Schendel
9 views•10 min read
•about 5 hours ago•GHSA-JP3C-6V3G-MPXV
6.5

GHSA-jp3c-6v3g-mpxv: Uncaught Runtime Panic via Integer Underflow in insomniacslk/dhcp BroadcastRawUDPConn

A denial-of-service vulnerability exists in the Go library github.com/insomniacslk/dhcp within the dhcpv4/nclient4 subpackage. In affected versions, the raw packet parsing function BroadcastRawUDPConn.ReadFrom subtracts the fixed 8-byte UDP header length from the IPv4 payload length declared in the packet header without first verifying that the declared payload length is at least 8 bytes. An unauthenticated attacker on an adjacent local network segment can broadcast or unicast a malformed IPv4 packet with a declared payload length between 0 and 7 bytes, causing a signed integer underflow that passes a negative slice bound into buf.Consume and triggers an unhandled Go runtime panic.

Amit Schendel
Amit Schendel
6 views•12 min read
•about 6 hours ago•CVE-2026-63305
8.1

CVE-2026-63305: OS Command Injection in WWBN AVideo Standalone FFmpeg Script

CVE-2026-63305 (GHSA-g9x9-q7qj-6mv5) is an operating system command injection vulnerability affecting WWBN AVideo (formerly YouPHPTube) versions up to and including 29.0. The defect resides in the standalone FFmpeg execution handler at plugin/API/standAlone/ffmpeg.json.php. When assembling asynchronous post-processing commands, the script concatenates the notifyCode and callback properties from a decrypted payload directly into a shell command string without sanitization. An attacker capable of providing or forging a valid encrypted execution payload can inject shell metacharacters to achieve remote code execution under the privileges of the web server user.

Alon Barad
Alon Barad
6 views•10 min read