Nov 24, 2026·8 min read·3 visits
CakePHP's TwigView plugin prior to 1.3.3 and 2.1.2 registers PHP's native unserialize() function as a Twig filter without specifying ['allowed_classes' => false]. Applications passing user-controlled data to the |unserialize filter are vulnerable to PHP Object Injection (CWE-502).
The cakephp/twig-view plugin integrates the Twig templating engine into the CakePHP framework. Prior to versions 1.3.3 and 2.1.2, the UtilsExtension class exposes PHP's native unserialize() function as a Twig filter without restricting allowed classes. When untrusted data is passed into the unserialize filter within a template, an attacker can trigger PHP Object Injection and execute Property-Oriented Programming (POP) gadget chains, leading to arbitrary code execution or data manipulation.
The cakephp/twig-view package provides an integration layer between the CakePHP web application framework and the Twig templating engine. It supplies wrappers for standard CakePHP View operations along with custom Twig extensions that expose native PHP functions and framework utilities directly to view templates.
Among these extensions is Cake\TwigView\Twig\Extension\UtilsExtension, which registers utility filters such as md5, base64_encode, base64_decode, serialize, and unserialize. These filters allow template authors to transform variables inline during the view rendering phase.
In versions prior to 1.3.3 and 2.1.2, the UtilsExtension class mapped the unserialize Twig filter directly to PHP's built-in unserialize() function without enforcing class instantiation restrictions. This design introduces a Deserialization of Untrusted Data vulnerability (CWE-502).
When a Twig template applies the |unserialize filter to untrusted input—or when an attacker achieves Server-Side Template Injection (SSTI) in a constrained environment—the application will deserialize arbitrary PHP objects. This enables attackers to leverage Property-Oriented Programming (POP) gadget chains present in the CakePHP core or installed Composer dependencies to achieve remote code execution.
The root cause of CVE-2026-59192 resides in how Cake\TwigView\Twig\Extension\UtilsExtension::getFilters() defines the unserialize filter. When registering a Twig\TwigFilter in PHP, providing a string callable such as 'unserialize' instructs Twig to pass the filtered template value directly as the first argument to the native unserialize(string $data, array $options = []) function.
By default, when the second $options argument is omitted from PHP's unserialize(), the runtime defaults to ['allowed_classes' => true]. In this mode, the PHP engine parses the serialized payload and instantiates any class referenced in the byte stream (O:<length>:"<ClassName>":...) provided the class is currently defined or can be loaded via Composer's registered PSR-4 autoloaders.
During and after the deserialization lifecycle, the PHP engine automatically invokes specific magic methods on the newly reconstructed objects. Specifically, __wakeup() or __unserialize() is triggered immediately upon object creation, __toString() is invoked if the template attempts to render or concatenate the resulting object, and __destruct() is guaranteed to execute when the object reference count drops to zero or at the end of the HTTP request lifecycle.
Because no boundary check or allowed_classes policy is enforced by UtilsExtension, the filter fails to restrict deserialization to safe scalar values and arrays. Any class within the application's autoloading scope that defines side effects inside these lifecycle methods becomes a potential execution gadget.
The vulnerability was addressed in commits 99a59407b138a0efff0ce3896cbf67e71a9c9cd3 (for the 2.x branch) and 65f5035ee65e76925242fdca2dc2bb0d732b6c1d (backported to the 1.x branch). The patch modifies src/Twig/Extension/UtilsExtension.php to wrap the native serialize and unserialize calls inside anonymous closures.
@@ -20,6 +20,7 @@
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;
+use function Cake\Core\deprecationWarning;
/**
* Class UtilsExtension.
@@ -34,8 +35,16 @@ class UtilsExtension extends AbstractExtension
public function getFilters(): array
{
return [
- new TwigFilter('serialize', 'serialize'),
- new TwigFilter('unserialize', 'unserialize'),
+ new TwigFilter('serialize', function (string $value): mixed {
+ deprecationWarning('5.0.2', 'Usage of serialize in templates deprecated.');
+
+ return serialize($value);
+ }),
+ new TwigFilter('unserialize', function (string $value): mixed {
+ deprecationWarning('5.0.2', 'unserialize is deprecated. Its usage creates arbitrary object deserialization issues');
+
+ return unserialize($value, ['allowed_classes' => false]);
+ }),
new TwigFilter('md5', 'md5'),
new TwigFilter('base64_encode', 'base64_encode'),
new TwigFilter('base64_decode', 'base64_decode'),The patched implementation replaces the direct 'unserialize' callable with a closure that explicitly passes ['allowed_classes' => false] as the second parameter to unserialize(). Furthermore, the closure enforces a string type hint on the $value input and emits a runtime deprecation warning via Cake\Core\deprecationWarning().
When ['allowed_classes' => false] is active, PHP continues to deserialize primitive types (int, float, bool, string) and array structures normally. However, if the serialized string contains an object payload, the engine does not instantiate the target class or trigger autoloaders; instead, it encapsulates the object properties inside a benign __PHP_Incomplete_Class instance.
> [!NOTE]
> Because __PHP_Incomplete_Class has no methods and does not invoke __wakeup(), __unserialize(), __toString(), or __destruct() from the target class definition, the patch completely neutralizes PHP Object Injection through the unserialize filter.
Exploiting CVE-2026-59192 requires a pathway where attacker-controlled data is passed into the |unserialize filter during template evaluation. This typically occurs in two scenarios: an application explicitly passes untrusted data (such as a cookie, database record, or form parameter) to |unserialize in an existing .twig template, or an attacker exploits a Server-Side Template Injection (SSTI) flaw where the Twig environment restricts direct function execution (e.g., via sandbox policies or limited registered functions) but permits the default UtilsExtension filters.
In a vulnerable template, the filter usage may appear as an assignment or an inline property access:
{# Scenario 1: Direct assignment of unserialized user payload #}
{% set data = user_input|unserialize %}
{# Scenario 2: Inline array access on unserialized data #}
{{ (user_input|unserialize)["attribute"] }}The upstream patch includes a regression test (tests/TestCase/Twig/Extension/UtilsExtensionTest.php) that demonstrates how object deserialization triggers magic methods during template rendering. The test defines a GadgetMarker class with a __wakeup() method:
namespace TestApp;
class GadgetMarker
{
public static bool $woken = false;
public function __wakeup(): void
{
self::$woken = true;
echo " [!] GadgetMarker::__wakeup fired during unserialize (object injection)\n";
}
}When the serialized string O:20:"TestApp\GadgetMarker":0:{} is passed into the payload variable of the template {% set _ = payload|unserialize %}, an unpatched version of cakephp/twig-view instantiates TestApp\GadgetMarker and immediately executes __wakeup(). In a real-world attack against a CakePHP application, an attacker would substitute GadgetMarker with known POP gadget chains from libraries commonly bundled with CakePHP and Twig (such as Guzzle, Monolog, or Symfony components, often generated via tools like phpggc) to achieve arbitrary file deletion, file write, or OS command execution.
The primary security impact of CVE-2026-59192 is arbitrary object instantiation leading to Remote Code Execution (RCE), arbitrary file manipulation, or application-level denial of service, depending on the POP gadgets available in the application's Composer autoload path. Because CakePHP applications rely on an extensive ecosystem of third-party Composer packages, viable gadget chains are frequently present in production deployments.
The vulnerability is assigned a CVSS v4.0 base score of 6.9 (Medium) with the vector CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:L/VA:N/SC:N/SI:N/SA:N. While the official CVSS v4.0 vector conservatively scores the baseline integrity impact as Low (VI:L) due to the conditional requirement that a template must actually apply the filter to untrusted input, the practical consequence in affected applications is full compromise of the web server process user.
Furthermore, within the context of Twig template engines, safe template design often assumes that filters only perform data transformation without side effects. Having an unrestricted unserialize filter enabled by default violates this boundary and provides an immediate escalation path if untrusted users are permitted to edit or customize view templates (such as custom email templates or CMS themes).
According to Exploit Prediction Scoring System (EPSS) metrics, the vulnerability carries a score of 0.00608 (49.81th percentile), and it is not currently listed in the CISA Known Exploited Vulnerabilities (KEV) catalog. The likelihood of remote exploitation depends entirely on whether an application exposes a template path using |unserialize on external input.
To remediate CVE-2026-59192, upgrade the cakephp/twig-view package to a patched release using Composer. For applications running the 1.x release stream, upgrade to version 1.3.3 or later. For applications on the 2.x release stream (CakePHP 5.x compatible), upgrade to version 2.1.2 or later.
# For 1.x branch deployments
composer require "cakephp/twig-view:^1.3.3"
# For 2.x branch deployments
composer require "cakephp/twig-view:^2.1.2"Because the CakePHP maintainers have officially deprecated both the serialize and unserialize filters in UtilsExtension, development teams should audit their codebase to remove any reliance on PHP serialization within Twig templates. Security and engineering teams can scan their template directories using grep to identify any active usage of the vulnerable filter:
grep -rnE '\|\s*unserialize' templates/If structured data needs to be decoded or encoded within templates or passed across state boundaries, refactor the application to use JSON (json_encode and json_decode) rather than native PHP serialization. If upgrading the package immediately is not possible, a temporary workaround is to override or unregister UtilsExtension in the application's TwigView configuration, or overwrite the unserialize filter on the Twig Environment instance with a custom TwigFilter that enforces ['allowed_classes' => false].
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:L/VA:N/SC:N/SI:N/SA:N| Product | Affected Versions | Fixed Version |
|---|---|---|
cakephp/twig-view cakephp | < 1.3.3 | 1.3.3 |
cakephp/twig-view cakephp | >= 2.0.0, < 2.1.2 | 2.1.2 |
| Attribute | Detail |
|---|---|
| Vulnerability Type | CWE-502: Deserialization of Untrusted Data |
| Affected Component | Cake\TwigView\Twig\Extension\UtilsExtension |
| CVSS v4.0 Score | 6.9 Medium (CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:L/VA:N/SC:N/SI:N/SA:N) |
| EPSS Score | 0.61% (49.81th Percentile) |
| Attack Vector | Network (PHP Object Injection via Twig |unserialize filter) |
| Impact | Arbitrary Object Instantiation / Potential Remote Code Execution via POP Gadgets |
| Patched Versions | 1.3.3, 2.1.2 |
| CISA KEV Status | Not Listed |
The application deserializes untrusted data without sufficiently verifying that the resulting data will be valid, allowing the creation of unexpected objects and execution of arbitrary code via gadget chains.
CVE-2026-63402 is a prototype-chain traversal and shared built-in object corruption vulnerability in the i18next internationalization framework for JavaScript prior to version 26.3.4. The flaw resides in the deepExtend utility function within src/utils.js, which uses the JavaScript 'in' operator to verify property existence on target objects. When an application passes untrusted resource bundles to i18next.addResourceBundle() with both the deep and overwrite parameters set to true, an attacker can traverse into inherited methods on Object.prototype and overwrite properties on shared built-in function objects, causing process-wide denial of service.
CVE-2026-58262 (tracked internally as KLR-04 and via GitHub Security Advisory GHSA-f9h7-4mmq-vgcq) is a cryptographic verification and consensus quorum bypass vulnerability in Klever-Go (`klever-io/klever-go`), the Go implementation of the Klever blockchain protocol. Prior to version 1.7.20, the block header signature verification logic (`HeaderSigVerifier.verifyConsensusSize`) counts all set bits across the entire `PubKeysBitmap` byte slice toward the required two-thirds validator quorum without masking or validating unused trailing padding bits in the final byte. Because the underlying Boneh-Lynn-Shacham (BLS) multi-signature verification function (`blsMultiSigner.Verify`) iterates strictly over the indices of configured validator public keys, it ignores any bits set at indices beyond the active consensus group size. When the consensus group size is not an exact multiple of 8, a compromised or malicious block producer can set these unused trailing padding bits to artificially inflate the apparent signer count by up to 7 signatures, enabling blocks with fewer genuine validator signatures than required by the protocol to pass consensus validation.
CVE-2026-77423 is a Regular Expression Denial of Service (ReDoS) vulnerability in the built-in less viewer of the JLine Java library (versions 3.0.0 prior to 3.30.15, and 4.0.0 prior to 4.3.1). The org.jline.builtins.Less class passes user-supplied search and display-filter patterns directly to Java's standard backtracking regular expression engine without complexity validation or execution timeouts. An attacker with access to an interactive JLine session can submit patterns containing nested quantifiers, causing catastrophic backtracking that consumes 100% of a CPU core and blocks the session thread indefinitely. In network-facing deployments such as SSH or Telnet administration consoles, repeated exploitation across concurrent sessions can exhaust bounded worker thread pools and result in a complete denial of service.
CVE-2026-63492 is a rejected CVE identifier originally assigned by GitHub for an OS command injection vulnerability in WWBN AVideo (formerly YouPHPTube) up to version 29.0. It was rejected as a duplicate of the canonical identifier CVE-2026-63304 (tracked under GHSA-j44m-77cc-p3cc). The flaw resides in the listFFmpegProcesses() function within plugin/API/standAlone/functions.php, which interpolates unsanitized user parameters directly into a single-quoted shell pipeline executed via PHP's exec() function. Attackers capable of crafting a valid AES-256-CBC encrypted API payload can break out of the single-quoted context and execute arbitrary operating system commands as the web-server user.
CVE-2026-63476 is an uncontrolled resource consumption vulnerability in isomorphic-git prior to version 1.38.6. When parsing Git packfile delta objects during clone or fetch operations, the applyDelta utility reads an untrusted targetSize integer from the delta stream header and passes it directly to Buffer.alloc(). A malicious remote Git server or man-in-the-middle attacker can supply a delta header specifying a targetSize of approximately 2 GB with minimal actual payload data. Because Buffer.alloc() reserves off-heap memory in Node.js, this bypasses standard V8 heap limits and results in immediate out-of-memory termination or sustained memory retention.
CVE-2026-63410 (GHSA-vp2j-gqfm-r3cf) is a compiler-induced timing side-channel vulnerability in the secp256k1-native Ruby C extension. When compiled with GCC 14.x or 15.x at optimization level -O2, the compiler reconstructs boolean predicates from branchless bitwise multiplexer routines and emits secret-dependent conditional jump instructions (je/jne). During elliptic curve scalar multiplication in the Montgomery ladder, these conditional branches create observable execution timing variations correlated with individual bits of secret private keys or signing nonces.