Dev.to Security πŸ” Cybersecurity πŸ‘ 0 πŸ“– 2 min read

CVE-2026-59192: CVE-2026-59192: Unsafe Deserialization in CakePHP TwigView UtilsExtension

CVE-2026-59192: Unsafe Deserialization in CakePHP TwigView UtilsExtension Vulnerability ID: CVE-2026-59192 CVSS Score: 6.9 Published: 2026-11-24 The cakephp/twig-view plugin integrates the Twig templating engine int

CVE-2026-59192: Unsafe Deserialization in CakePHP TwigView UtilsExtension

Vulnerability ID: CVE-2026-59192
CVSS Score: 6.9
Published: 2026-11-24

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.

TL;DR

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).

⚠️ Exploit Status: POC

Technical Details

  • 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

Affected Systems

  • cakephp/twig-view
  • cakephp/twig-view: < 1.3.3 (Fixed in: 1.3.3)
  • cakephp/twig-view: >= 2.0.0, < 2.1.2 (Fixed in: 2.1.2)

Code Analysis

Commit: 99a5940

Fix deserialization of untrusted data weakness (#119)

@@ -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'),

Commit: 65f5035

Backport fix for deserialization of untrusted data (#120)

Mitigation Strategies

  • Upgrade cakephp/twig-view to version 1.3.3 (for 1.x) or 2.1.2 (for 2.x) to enforce ['allowed_classes' => false] during deserialization.
  • Eliminate the use of native PHP serialization (|serialize and |unserialize) in Twig templates in favor of JSON encoding.
  • Audit all Twig templates for occurrences of the |unserialize filter applied to user-supplied or externally sourced variables.

Remediation Steps:

  1. Run grep -rnE '\|\s*unserialize' templates/ across the project repository to locate templates utilizing the unserialize filter.
  2. Update composer.json and run composer require "cakephp/twig-view:^1.3.3" (for 1.x) or composer require "cakephp/twig-view:^2.1.2" (for 2.x).
  3. Verify that deprecation warnings for serialize and unserialize are not triggered during test suite execution.
  4. Replace any necessary data serialization in views with json_encode and json_decode.

References

Read the full report for CVE-2026-59192 on our website for more details including interactive diagrams and full exploit analysis.

πŸ“° Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.