Summary
openITCOCKPIT contains an unsafe deserialization sink in its Gearman worker implementation, where job payloads are passed directly to PHP's unserialize() without class restrictions or provenance checks.
In deployments where the Gearman service is reachable from untrusted systems, attackers may submit crafted job payloads that trigger PHP Object Injection in the worker process, potentially leading to remote code execution under the worker's privileges.
Affected context
This vulnerability occurs in openITCOCKPIT installations that use the Gearman worker functionality and process serialized job payloads via PHP.
The design assumes that only trusted internal components enqueue Gearman jobs, but this assumption is not enforced in the worker code.
The issue becomes particularly relevant when:
- The Gearman service listens on non-localhost interfaces
- Network access to TCP port 4730 is not tightly restricted
- Untrusted or semi-trusted systems can submit Gearman jobs into the same queue
Exploit preconditions
- Attack surface: Gearman job queue exposed over TCP (typically port 4730)
- Required access: Ability to connect to the Gearman service and enqueue jobs to the
oitc_gearmanworker function (no application-level authentication enforced at the sink) - Trigger point: Processing of a Gearman job where the payload is passed to
unserialize()inside the worker process - Why exploitation is possible:
- The worker calls
unserialize()on job payloads without: - Restricting which PHP classes can be instantiated
- Validating or authenticating the source of the job data
- PHP Object Injection becomes possible if any autoloaded or included class in the application has magic methods (
__wakeup,__destruct, etc.) that can be abused for unintended behavior
Why this happens
The core issue aligns with CWE-502: Deserialization of Untrusted Data.
The Gearman worker implementation in openITCOCKPIT assumes that all Gearman job payloads are trustworthy and thus calls PHP's unserialize() directly on incoming data.
Deserialization in PHP is not a purely data-oriented operation: it reconstructs full object graphs and triggers magic methods, which can be leveraged when any gadget chain exists in the codebase or its dependencies.
Because the code does not enforce a strong trust boundary, does not restrict which classes may be instantiated, and does not perform input validation or integrity checks, arbitrary attacker-controlled serialized data can be interpreted as logic rather than simple data.
Potential impact
- Remote code execution within the Gearman worker process, subject to the worker's OS and application privileges
- Execution of attacker-controlled methods via PHP Object Injection gadget chains
- Manipulation or corruption of monitoring configuration or state handled by the worker
- Unauthorized access to or modification of monitored data, alerts, or metrics
- Lateral movement within the infrastructure if the worker has access to other internal services or credentials
- Denial of service by causing crashes or resource exhaustion in the worker
General mitigation guidance
Risk reduction for this class of vulnerability typically focuses on eliminating unsafe deserialization and enforcing trust boundaries in code, rather than relying solely on network layout or assumptions about internal components.
Useful defensive patterns include:
- Avoiding use of
unserialize()for data that may traverse network boundaries; prefer structured, data-only formats such as JSON withjson_encode/json_decodeor other typed, schema-based encodings. - If deserialization is unavoidable, using mechanisms that:
- Whitelist allowed classes or types
- Reject unexpected or unknown types
- Treat incoming payloads as data, not as arbitrary object graphs
- Applying explicit authentication or integrity controls to job payloads, such as:
- Cryptographic signatures over messages to ensure they originate from trusted producers
- Strict association between worker queues and authenticated producers
- Minimizing the set of loaded classes and "gadget" functionality in worker processes, and avoiding magic methods with side effects that can be triggered during object construction or destruction.
- Running Gearman workers and associated processes with least privilege, separating them from other sensitive components and restricting filesystem, network, and credential access.
- Configuring network-level controls so that queues intended to be internal are not inadvertently exposed, recognizing that network controls complement but do not replace secure coding patterns.
How teams detect issues like this
Detection often combines code-centric and environment-centric approaches:
- Static analysis and code scanning:
- Search for direct usage of
unserialize()on data influenced by external input, particularly in worker, queue, or message-handling code. - Define static analysis rules or linters that flag unsafe deserialization APIs and require justification or secure wrappers.
- Look for magic methods (
__wakeup,__destruct,__sleep,__toString) in classes that perform I/O, execute commands, or modify global state, as they can form gadget chains. - Code review practices:
- Treat any use of
unserialize()or similar APIs as a security-sensitive hotspot that mandates review. - Verify that trust boundaries are enforced in code, not only documented or assumed at the infrastructure level.
- Check that job-processing logic validates payload structure and origin before acting on it.
- Runtime and operational monitoring:
- Monitor Gearman endpoints for unusual job sources, atypical payload sizes, or patterns of malformed jobs.
- Log and review deserialization errors, unexpected exceptions in workers, or anomalous worker restarts, which may indicate probing attempts.
- Automated tools and policy:
- Integrate SAST tools into CI/CD pipelines with rules for unsafe deserialization.
- Enforce coding policies that ban or tightly constrain dangerous APIs like
unserialize()in new code.

