/

CVE-2026-42473

Severity:

CRITICAL RISK

(9.8)

Unsafe Deserialization in MixPHP Framework File-Based

CVE-2026-42473

Deferred

Vulnerability type

Category:

Unsafe Deserialization

CWE:

CWE-502

Impact:

Remote Code Execution

Severity:

CRITICAL RISK

(9.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

MixPHP Framework 2.x through 2.2.17 contains an unsafe deserialization flaw where the FileHandler session and cache components invoke PHP's unserialize() on data read from the filesystem.

If an attacker can influence or control the contents of these serialized files, they may be able to trigger arbitrary object instantiation and potentially achieve remote code execution within the application context.

Affected context

This vulnerability is present in MixPHP applications that use the framework's file-based session or cache handlers.

The risk is most pronounced when:

  • Session or cache storage is configured to use the vulnerable FileHandler
  • File storage paths are writable and potentially exposed to other local processes, users, or compromised components
  • Application code or installed libraries define PHP magic methods (e.g., __wakeup, __destruct) with side effects that can be abused when objects are unserialized

The vulnerability does not depend on a specific business feature; it is tied to how session and cache data are serialized and later deserialized from disk.

Exploit preconditions

  • Attack surface: Server-side, via file-based session or cache storage that is later processed by MixPHP using unserialize().
  • Required access: Ability to influence or write serialized data into files that the FileHandler will read (e.g., through session fixation/poisoning, local file write primitives, shared hosting scenarios, or compromise of an adjacent component).
  • Trigger point: The next request or operation that causes MixPHP's FileHandler to load a session or cache entry and call unserialize() on its content.
  • Why exploitation is possible: PHP's unserialize() treats the input as a serialized object graph without enforcing type or class constraints, allowing attacker-controlled data to instantiate arbitrary classes and invoke magic methods, matching the unsafe deserialization pattern in CWE-502.

Why this happens

The core issue is the direct use of PHP's unserialize() on data that is not strongly authenticated or constrained, in the FileHandler used for session and cache storage.

This creates a classic CWE-502: Deserialization of Untrusted Data scenario, where:

  • Data stored to disk is later treated as trusted, despite potential tampering or cross-tenant write access.
  • The deserialization process can instantiate arbitrary classes available in the application and its dependencies.
  • Magic methods (such as __wakeup, __sleep, __destruct) or other lifecycle hooks in those classes may perform file operations, command execution, or further dynamic behavior.

Instead of treating stored session and cache entries as opaque, primitive values, the framework rehydrates full PHP object graphs from the filesystem, extending the application's trust boundary to any actor able to alter those files.

Potential impact

  • Remote code execution in the context of the web server process via gadget chains in application or library classes
  • Access to or modification of sensitive session data, potentially leading to account takeover or privilege escalation
  • Manipulation of cached application state, impacting business logic or integrity of responses
  • Lateral movement within the hosting environment by leveraging filesystem and OS-level privileges of the application
  • Data disclosure through deserialization side effects that expose configuration or internal state

General mitigation guidance

Effective mitigation focuses on reducing trust in serialized data and avoiding unserialize() for session and cache storage:

  • Prefer serialization formats that do not support object graphs, such as JSON or other primitive-only encodings, for session and cache values.
  • Treat session and cache backends as untrusted storage, enforcing strict validation, type checks, and casting when data is read back.
  • Avoid storing full object instances in sessions or cache; store only scalar values or simple arrays and reconstruct objects explicitly when needed.
  • Minimize or refactor PHP classes that implement magic methods with side effects that can be triggered on object construction, wakeup, or destruction.
  • Consider using signed or authenticated session/cache tokens to detect tampering, while still avoiding unserialize() for core parsing.
  • Apply least-privilege for the web server and PHP processes, limiting filesystem and OS capabilities so that deserialization abuse has reduced impact.

How teams detect issues like this

Detection typically combines code-level analysis with configuration review:

  • Use static analysis (SAST) rules to flag calls to unserialize(), especially within framework infrastructure like session and cache handlers.
  • During code review, scrutinize any data flows where serialized data is written to and later read from disk or other storage backends, and verify that the data origin is truly trusted.
  • Inventory classes across the application and dependencies that define __wakeup, __destruct, or __toString, and assess whether they perform sensitive operations that could be chained into a gadget.
  • Incorporate security-focused linters or automated review tools into CI to block new uses of unserialize() and to enforce safer serialization practices.
  • Monitor application logs and telemetry for anomalous session or cache behavior, such as unexpected object types found in session state or sudden changes in file sizes and access patterns in session/cache directories.

Sources

SourceLink
gist.github.comgist.github.com/sgInnora/fa46386840fe978a30d7e53c458f2975
github.comgithub.com/mix-php/mix
github.comgithub.com/mix-php/mix/blob/v2.2.17/src/sync-invoke/src/Server.php

Frequently asked

questions

It can be remotely exploitable if an attacker can indirectly control the contents of session or cache files (for example, through session poisoning or another vulnerability that allows writing those files). If only local users or processes can modify those files, the exploitability is limited to those actors.

An attacker must be able to influence the serialized data that the FileHandler will later read and pass to unserialize(). This could be through application-level inputs that end up in serialized form, write access to the session/cache directories, or compromise of a neighboring application sharing the same filesystem.

The safest pattern is to remove reliance on unserialize() for session and cache data. Adopt a simple, non-object serialization format such as JSON, store only primitive or array data, and reconstruct objects manually. Additionally, audit the framework configuration to ensure file-based handlers are not using unsafe deserialization.

Establish a project-wide policy that forbids unserialize() on data that may leave process memory, favoring safe formats like JSON. Combine this with secure coding guidelines, static analysis checks, and code review practices that treat session, cache, and other persistence layers as untrusted, requiring explicit validation and type enforcement on all deserialized data.

Find out what's already
exploitable in your codebase.