Summary
MixPHP Framework 2.x through 2.2.17 contains an unsafe deserialization flaw where the Redis-backed session and cache handlers call unserialize() on data retrieved from Redis without sufficient trust boundaries.
If an attacker can influence or inject serialized payloads into the Redis store, they may be able to trigger gadget chains in the PHP application, potentially leading to remote code execution or complete application compromise.
Affected context
This vulnerability appears in applications built on MixPHP Framework 2.x–2.2.17 that use the Redis-based session or cache storage via the RedisHandler object.
It is relevant where:
- PHP's native
unserialize()is used for restoring session or cache data from Redis - Redis is reachable by multiple services or tenants, or is otherwise not fully isolated
- Application code or third-party libraries include classes with magic methods (e.g.,
__wakeup,__destruct) that can form deserialization gadget chains
The issue is most severe when Redis content can be modified by attackers directly or indirectly through other vulnerable components.
Exploit preconditions
- Attack surface: Application instances using MixPHP Redis session or cache handlers.
- Required access: Ability to write or manipulate serialized data stored in Redis (e.g., compromised Redis, weak isolation, SSRF into Redis, or another flaw that lets an attacker control data before it is stored).
- Trigger point: Any request that causes MixPHP to read from Redis and call
unserialize()in theRedisHandlerfor session restoration or cache retrieval. - Why exploitation is possible:
unserialize()treats attacker-controlled strings as PHP object graphs, allowing invocation of methods on existing classes that may perform sensitive actions during object construction, wakeup, or destruction.
Why this happens
The core issue is the use of PHP's unserialize() on data that is not guaranteed to be fully trusted or integrity-protected.
This maps directly to CWE-502: Deserialization of Untrusted Data, where serialized representations are processed as executable object graphs.
In this pattern, the session and cache layers are implemented with generic serialization and deserialization logic instead of using safer formats (e.g., JSON) or strong authenticity checks.
As a result, if an attacker can introduce arbitrary serialized data into Redis, the framework will reconstruct objects with potentially dangerous magic methods, forming a gadget chain that can be abused for remote code execution or other high-impact actions.
Potential impact
- Execution of arbitrary PHP code via gadget chains in application or library classes
- Complete takeover of the web application runtime
- Unauthorized access to or modification of session data, including impersonation of other users
- Tampering with cached application data, leading to data integrity issues or logic manipulation
- Pivoting to backend systems, such as databases or internal services, using compromised application privileges
General mitigation guidance
Effective mitigation centers on avoiding unsafe deserialization and tightening trust around stateful data:
- Replace
unserialize()for session and cache data with safer, data-only formats such as JSON, CBOR, or msgpack that do not rehydrate PHP objects. - If legacy serialization must be preserved, enforce strong integrity and authenticity controls (e.g., HMAC signing of values) so only framework-generated data is ever deserialized.
- Restrict the set of classes that can be instantiated from serialized data by using structured, explicit mapping or whitelisting patterns.
- Limit the presence of dangerous magic methods (
__wakeup,__destruct,__toString, etc.) in classes that can appear in serialized data, and ensure such methods avoid performing side effects on deserialization. - Harden Redis deployment: isolate it per application, require authentication, and restrict network access to trusted clients, reducing opportunities for data injection.
- Apply least-privilege principles so that, even if exploitation occurs, the PHP process and its associated credentials have minimal access.
How teams detect issues like this
Teams can identify and monitor this issue through a combination of static and runtime techniques:
- Use static analysis or code search to detect calls to
unserialize()in session, cache, or other I/O-adjacent components, especially within the Redis handler. - During code review, flag usage of generic serialization for cross-boundary data (e.g., cache, sessions, queues, or messages) and require justification or alternative patterns.
- Implement security-focused unit and integration tests that attempt to deserialize crafted payloads, verifying that unsafe behavior is not reachable.
- Configure application firewalls, logging, and monitoring to alert on unexpected Redis access patterns, anomalous serialized payloads, or unusual error traces linked to deserialization.
- Optionally employ SAST/IAST tools capable of modeling data flow from external sources into
unserialize()to detect deserialization of potentially untrusted data.

