Summary
Zumba Json Serializer up to version 3.2.2 allows PHP object deserialization from JSON using a special @type field that can instantiate arbitrary classes.
When untrusted JSON is passed to JsonSerializer::unserialize(), an attacker may trigger PHP Object Injection and potentially achieve Remote Code Execution if suitable gadget chains exist in the application or its dependencies.
Affected context
This vulnerability appears in PHP applications that:
- Use Zumba Json Serializer (version 3.2.2 and below)
- Call
JsonSerializer::unserialize()on JSON that may include attacker-controlled data - Run code where application or library classes implement magic methods (
__wakeup,__destruct,__toString, etc.) with side effects
The issue is exposed when JSON input can carry a @type field that the library uses to instantiate PHP objects during deserialization, without restricting which classes can be created.
Exploit preconditions
- Attack surface: JSON deserialization endpoints, APIs, background jobs, or message consumers that call
JsonSerializer::unserialize()on input not fully controlled by the server. - Required access: Ability to supply or influence JSON data processed by the vulnerable deserialization call (e.g., HTTP request bodies, messages, configuration values).
- Trigger point: Invocation of
JsonSerializer::unserialize()on JSON containing an attacker-chosen@typevalue and properties that satisfy a gadget chain. - Why exploitation is possible: The deserializer trusts the
@typefield and instantiates any referenced class without restriction, enabling object graphs that can invoke dangerous magic methods during construction, wakeup, or destruction.
Why this happens
The core issue is an unsafe deserialization pattern where JSON data is treated as an instruction set for object construction.
Zumba Json Serializer supports a special @type field in JSON that maps directly to PHP class names. When deserializing, it creates an instance of whichever class is specified, populating its properties from the JSON content.
This aligns with CWE-502: Deserialization of Untrusted Data, because untrusted JSON is allowed to control object types and state. In environments where classes implement side-effectful magic methods (__wakeup, __destruct, __toString, etc.), crafted payloads can assemble gadget chains that execute logic unintended by the application, including file write, command execution, or other security-sensitive operations.
Potential impact
- Attackers may instantiate arbitrary classes available in the application or its dependencies.
- PHP Object Injection that can alter internal object state and application flow.
- Execution of dangerous magic methods as part of object lifecycles, potentially leading to:
- Remote Code Execution, if a suitable gadget chain is present
- Arbitrary file read/write or deletion
- SSRF or outgoing HTTP requests to attacker-controlled endpoints
- Authentication or authorization bypass via tampering with security-related objects
- Denial of Service by triggering expensive operations or resource exhaustion
General mitigation guidance
Effective mitigation focuses on reducing trust in serialized data and limiting what deserialization is allowed to construct:
- Avoid deserializing untrusted or externally supplied JSON with
JsonSerializer::unserialize(); treat any data crossing a trust boundary as untrusted. - Prefer safe, schema-based JSON handling where inputs are decoded into arrays or simple value objects, then explicitly mapped to domain models.
- Disable or avoid
@type-based object instantiation wherever possible, favoring whitelists or explicit, server-side selection of types rather than client-provided type names. - Constrain the set of allowable classes for deserialization using allowlists or dedicated DTOs that do not implement dangerous magic methods.
- Refactor or minimize side effects in magic methods (
__wakeup,__destruct,__toString, etc.), especially in classes reachable from user-controlled data, so that inadvertent object instantiation is less risky. - Apply least-privilege principles to the runtime (file system permissions, command execution capabilities, network egress) to reduce the blast radius if a gadget chain is ever triggered.
How teams detect issues like this
Detection typically combines static analysis, code review, and runtime monitoring:
- Static analysis patterns:
- Search for calls to
JsonSerializer::unserialize()or similar deserialization APIs that receive data from HTTP requests, queues, logs, or other untrusted sources. - Flag configuration or code paths that allow a
@typefield from input to influence class selection without an explicit allowlist. - Identify classes with magic methods that interact with the file system, process execution, or external services and are reachable through object graphs.
- Code review signals:
- Deserialization in controllers, middleware, or message handlers without clear trust boundaries or validation.
- Business logic that relies on deserialized objects rather than explicit data transfer objects.
- Libraries or application domains with complex magic methods that perform privileged operations.
- Policy enforcement:
- Introduce coding standards that forbid unsafe deserialization of untrusted data and require use of safe JSON parsing and DTO mapping.
- Integrate automated code review tools or SAST solutions to enforce rules around object deserialization and magic method usage.

