Summary
c3p0 ConnectionPoolDataSource implementations prior to 0.12.0 unsafely deserialize hex-encoded Java objects stored in the userOverridesAsString property, and can follow embedded JNDI Reference values to remote locations.
Under conditions where an attacker can reset this property or supply malicious serialized objects or JNDI references, the application's CLASSPATH may be abused to load and execute arbitrary code from local or remote sources.
Affected context
The vulnerability appears in Java applications that:
- Use c3p0 ConnectionPoolDataSource implementations prior to version 0.12.0
- Rely on the
userOverridesAsStringJavaBean property to configure user-specific overrides - Expose these DataSource instances or their configuration across JNDI, serialized objects, or other dynamic configuration channels
In such environments, hex-encoded serialized Java objects and embedded javax.naming.Reference values can be processed without sufficient validation or restrictions, creating an unsafe bridge between configuration data and executable code.
Exploit preconditions
- Attack surface: Application components that consume or expose c3p0 ConnectionPoolDataSource objects, including:
- JNDI-based DataSource lookups
- Serialized configuration or object streams
- Bean property setters for
userOverridesAsString - Required access: Ability to influence or reset the
userOverridesAsStringproperty, or inject malicious serialized objects / JNDIReferenceinstances that will be processed by c3p0 and mchange-commons-java code. - Trigger point: Deserialization of the hex-encoded
userOverridesAsStringcontent and dereferencing of embeddedjavax.naming.Referenceobjects, which may include remotefactoryClassLocationvalues. - Why exploitation is possible: The property is backed by generic Java serialization and early-style JNDI logic. Deserialization trusts attacker-controlled object graphs, and JNDI references can dynamically resolve classes from remote locations without gating or strict policy checks, mapping directly to CWE-502 (unsafe deserialization) and CWE-94 (code injection).
Why this happens
At its core, the bug stems from using Java serialization as the backing format for a writable configuration property that can be exposed and mutated over JNDI and other remote interfaces. The userOverridesAsString property stores a conceptual Map<String, Map<String, String>> as hex-encoded serialized objects, and c3p0 implicitly trusts this serialized data.
When deserialized, the object graph may contain javax.naming.Reference instances that leverage legacy JNDI behavior in mchange-commons-java. Those references can specify remote factoryClassLocation values, which are resolved and used to instantiate classes, effectively turning configuration data into executable code. This pattern aligns with CWE-502: Deserialization of Untrusted Data because untrusted, attacker-controlled serialized objects are treated as authoritative, and CWE-94: Code Injection because attackers can influence which code is loaded and executed via JNDI-based class resolution. The architectural assumption that serialized objects are benign configuration rather than untrusted input creates the systemic fragility.
Potential impact
- Arbitrary code execution within the Java application process via malicious JNDI references and class loading
- Download and execution of attacker-controlled code from remote locations referenced by
factoryClassLocation - Compromise of database credentials and pooled connections managed by c3p0
- Full application takeover and potential lateral movement in the hosting environment
- Data corruption, exfiltration, or impersonation using compromised ConnectionPoolDataSource instances
General mitigation guidance
Pattern-based mitigation for this class of issue focuses on eliminating unsafe serialization in configuration paths and hardening dynamic code loading mechanisms:
- Prefer transparent, text-based configuration formats (such as CSV, JSON, or XML) over Java object serialization for properties that may be exposed through JNDI, configuration files, or remote beans.
- Enforce strict separation between configuration data and executable behavior: configuration values should not be able to dictate class locations or object types beyond a controlled whitelist.
- Gate all JNDI-based class resolution behind explicit policy, such as:
- Restricting remote
factoryClassLocationusage - Limiting allowed namespaces and class names to a curated set
- Disallowing arbitrary remote endpoints from determining class loading behavior
- Apply least-privilege principles to components that interact with JNDI and class loaders, reducing the blast radius if a misconfiguration is exploited.
- Treat any serialized input (including hex-encoded blobs) as untrusted unless it is generated and consumed in a tightly controlled context; avoid deserializing attacker-controllable data with general-purpose serialization frameworks.
How teams detect issues like this
Detection commonly centers around identifying unsafe deserialization paths, configuration-driven class loading, and overly permissive JNDI usage:
- Use static analysis to flag:
- Deserialization of data from configuration properties, JNDI lookups, and other dynamic sources
- Calls that instantiate or dereference
javax.naming.Referenceobjects, especially where remotefactoryClassLocationvalues are possible - Utility methods that wrap Java serialization or JNDI resolution without enforcing strict validation or whitelisting
- Conduct focused code reviews on:
- DataSource and connection pool configuration handling
- JavaBean properties that store complex object graphs or encoded serialized content
- Any glue code bridging JNDI, configuration storage, and class loading mechanisms
- Apply policy-based enforcement in CI/CD pipelines:
- Require justification and explicit patterns for JNDI usage and dynamic class loading
- Prohibit custom serialization formats for configuration unless they are schema-validated and non-executable
- Consider leveraging automated security tooling that can trace deserialization sinks and JNDI entry points, correlating them with attacker-controlled sources.

