/

CVE-2026-37552

Severity:

HIGH RISK

(8.4)

Unsafe Deserialization in MixPHP Sync-Invoke TCP Server

CVE-2026-37552

Analyzed

Vulnerability type

Category:

Unsafe Deserialization

CWE:

CWE-502

Impact:

Remote Code Execution over Localhost TCP

Severity:

HIGH RISK

(8.4)

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 in its sync-invoke TCP server, where data read from a localhost TCP socket is passed directly to Opis\Closure\unserialize() and then executed with call_user_func().

An attacker who can reach the bound localhost TCP port can send a crafted serialized PHP closure, leading to arbitrary code execution in the PHP process.

Affected context

This vulnerability appears in MixPHP applications that enable or deploy the sync-invoke TCP server component in versions 2.x through 2.2.17.

The server listens on 127.0.0.1 and accepts arbitrary TCP connections on its configured port without authentication or message integrity checks.

Any data received from this local TCP endpoint is treated as a serialized PHP closure, deserialized using Opis\Closure\unserialize(), and then invoked directly via call_user_func().

The risk is elevated in environments where:

  • Other local processes, users, or containers can open TCP connections to the service
  • The localhost boundary is not considered a strong security boundary (e.g., shared hosts, development desktops, CI runners)

Exploit preconditions

  • Attack surface: Local TCP port bound to 127.0.0.1 by the sync-invoke server
  • Required access: Ability to establish a TCP connection to the localhost port (e.g., code execution as the same OS user, another service on the host, or a container with network access to the host loopback)
  • Trigger point: Sending a specially crafted serialized PHP closure payload to the listening sync-invoke TCP endpoint
  • Why exploitation is possible:
  • Raw socket data is trusted as if it were a legitimate serialized closure
  • Opis\Closure\unserialize() is invoked on untrusted bytes
  • The resulting callable is immediately invoked with call_user_func() without validation, allowing attacker-controlled code to run

Why this happens

The core issue is an unsafe deserialization pattern: untrusted data from a TCP socket is directly deserialized into executable code constructs.

Specifically, the sync-invoke server:

  • Treats incoming TCP data as a serialized PHP closure payload
  • Uses Opis\Closure\unserialize() on this untrusted data, enabling construction of arbitrary closure objects
  • Immediately executes the deserialized closure via call_user_func() without authentication, authorization, or integrity checks

This behavior maps to CWE-502: Deserialization of Untrusted Data, where attacker-controlled serialized objects or closures are turned back into live code or objects and executed, breaking the intended trust boundary around the localhost interface.

Potential impact

  • Arbitrary PHP code execution within the MixPHP application process
  • Full compromise of the web application runtime and its configuration
  • Access to sensitive data handled by the application, including credentials and tokens
  • Lateral movement to connected databases, caches, and internal services via the compromised process
  • Use of the compromised application as a pivot point for further attacks within the host or network

General mitigation guidance

Effective mitigation focuses on eliminating the direct deserialization-and-execution of untrusted data and tightening the trust boundary around local IPC.

Pattern-based defensive strategies include:

  • Avoid deserializing executable constructs from untrusted sources:
  • Replace Opis\Closure\unserialize() with data-oriented serialization formats (e.g., JSON, protocol buffers) that cannot carry arbitrary code.
  • Design the protocol to pass identifiers and parameters, not code or closures.
  • Introduce strong authentication and integrity checks:
  • Require a shared secret, token, or mutual authentication on the TCP channel before processing requests.
  • Use message authentication codes (MACs) or signatures to ensure messages originate from trusted components.
  • Validate and constrain what can be executed:
  • Map incoming requests to a fixed set of allowed operations or handlers.
  • Avoid calling arbitrary callables; use whitelists and explicit dispatch tables.
  • Harden the runtime environment:
  • Run the sync-invoke server under a dedicated, least-privileged OS account.
  • Limit file system, network, and database privileges so that compromise has constrained blast radius.
  • Reconsider IPC design choices:
  • Prefer well-defined, typed, and schema-validated inter-process protocols instead of arbitrary object/closure serialization.
  • Treat localhost as a semi-trusted boundary and design with the assumption that other local processes may be malicious.

How teams detect issues like this

Detecting this vulnerability and similar patterns generally involves combining code-centric and runtime-centric approaches:

  • Static code analysis:
  • Search for calls to unserialize(), Opis\Closure\unserialize(), or similar APIs where the input originates from network sockets or other untrusted sources.
  • Flag patterns where deserialized values are passed into call_user_func(), call_user_func_array(), or other dynamic execution functions.
  • Enforce project-wide rules disallowing deserialization of closures or executable objects from external input.
  • Manual code review:
  • Inspect IPC, RPC, and "sync invoke" style components for protocols that transmit code or callables instead of data.
  • Review any code paths that trust localhost as inherently safe and accept raw serialized payloads.
  • Runtime and operational monitoring:
  • Monitor local TCP ports for unexpected connection sources and high-frequency or anomalous traffic patterns.
  • Enable application-level logging that records invocation sources, parameters, and unexpected failures in the sync-invoke server.
  • Security testing and CI integration:
  • Include deserialization-focused tests and fuzzing against internal endpoints, not just public HTTP interfaces.
  • Integrate automated tools that detect unsafe deserialization usage into CI pipelines to catch regressions early.

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

Not directly through the network interfaces described. The sync-invoke TCP server binds to 127.0.0.1, so exploitation generally requires the ability to connect to the localhost port. However, in shared environments, containers, or compromised hosts, local access may be easier to obtain than expected.

An attacker must be able to establish a TCP connection to the localhost port where the sync-invoke server is listening. This might come from another process on the same machine, a user with shell access, a compromised service, or in some cases a container or sandbox with access to the host's loopback network.

The safest approach is to stop deserializing and executing closures or other executable objects from any external input. Instead, redesign the protocol to exchange data only, authenticate requests on the TCP channel, and dispatch incoming messages to a fixed set of known handlers using explicit routing rather than dynamic invocation.

Avoid using generic serialization of code or objects for communication between components. Treat all external and inter-process inputs—including those over localhost—as untrusted, use data-only formats with schema validation, enforce strong authentication and integrity on internal protocols, and prohibit direct deserialization-to-execution patterns during code review and static analysis.

Find out what's already
exploitable in your codebase.