Summary
Cotonti CMS's Comments plugin deserializes attacker-controlled, base64-encoded request data without restricting which PHP classes may be instantiated. A member who can create or edit comments may trigger PHP object injection, potentially enabling property manipulation, unintended database actions, or further code execution when usable gadget chains are present.
Affected context
The issue occurs in the Comments plugin when comment creation or editing processes user-supplied ci or cb parameters. These values receive only trim-style text handling before base64 decoding and unserialization without an allowed_classes restriction. The create and edit paths may be available to ordinary members when they have comment write access, while a similar delete-path sink is restricted to administrators.
Exploit preconditions
- Attack surface: Cotonti Comments plugin comment creation and editing endpoints
- Required access: Membership with permission to create comments or edit the member's own comment
- Trigger point: Deserialization of the
ciorcbrequest parameter - Why exploitation is possible:
unserialize()accepts attacker-selected PHP object types after base64 decoding and does not restrict instantiated classes - Additional condition for impact: A suitable loaded class or gadget chain must provide a useful magic-method side effect
Why this happens
The vulnerable code treats client-controlled serialized data as trusted application state and passes it to PHP's unserialize() without an allowed_classes policy. PHP may instantiate classes present in the application's runtime, allowing magic methods such as destructors to execute during object lifecycle events. This is CWE-502: Deserialization of Untrusted Data and represents a PHP Object Injection primitive; the ultimate impact depends on available classes, gadget chains, and object properties accepted by those classes.
Potential impact
- An attacker may manipulate application-managed data through a usable gadget chain.
- Crafted objects could cause unintended database inserts or modifications.
- Application state, cache contents, or comment-related data could be corrupted.
- A suitable gadget chain may enable arbitrary code execution.
- The vulnerable application process or connected services could be compromised.
General mitigation guidance
Mitigation generally centers on eliminating unsafe deserialization of client-controlled data and reducing trust in serialized input.
Common defensive patterns include:
- Replace PHP object serialization with a constrained data format such as JSON and validate it against a strict schema.
- If deserialization is unavoidable, use an explicit class allowlist and reject unexpected object types before processing.
- Avoid invoking deserialization before authorization, integrity, and structural validation checks.
- Bind state to authenticated sessions or server-side storage instead of accepting reusable serialized state from clients.
- Apply least-privilege database and operating-system permissions to limit gadget-chain consequences.
- Keep administrative-only paths separately authorized and ensure equivalent unsafe sinks are not exposed through member workflows.
How teams detect issues like this
Organizations can look for this vulnerability through:
- Static analysis rules identifying
unserialize()applied to request, cookie, session, or decoded user input. - Code review searches for base64 decoding followed by deserialization and for missing
allowed_classesrestrictions. - Runtime monitoring of unusual serialized-object markers, repeated malformed parameters, or unexpected cache and database writes.
- Policy checks that prohibit PHP object deserialization at web-facing trust boundaries.
- Dependency and gadget-surface reviews that inventory classes with security-sensitive magic methods such as
__destruct(),__wakeup(), or__invoke().
Automated code-review tools may help identify unsafe data-flow paths, but findings should be validated against authorization and runtime class availability.

