Summary
mchange-commons-java contains a JNDI-like reference resolution mechanism that can honor remote factoryClassLocation values, enabling code to be downloaded and executed inside a running Java application.
If an attacker can cause the application to process a malicious javax.naming.Reference or serialized object, they may trigger arbitrary code execution even when the JDK's own JNDI protections are enabled.
Affected context
This vulnerability affects Java applications that:
- Include vulnerable versions of
mchange-commons-javaon the application CLASSPATH - Use its JNDI-like reference resolution paths directly or indirectly (for example via libraries such as c3p0)
- Accept or process
javax.naming.Referenceinstances or serialized objects that might originate from untrusted or partially trusted sources
The issue becomes relevant in environments where attackers can influence naming references, serialized payloads, or configuration/state passed into components that rely on mchange-commons-java's JNDI-like mechanisms.
Exploit preconditions
- Attack surface: Any code path that:
- Deserializes attacker-controlled objects that include
javax.naming.Reference-like data, or - Passes attacker-influenced
Referenceobjects into APIs backed by mchange-commons-java's JNDI-like implementation. - Required access: Ability to supply or manipulate naming references or serialized data consumed by the application (e.g., via network APIs, messaging systems, configuration channels, or persistence layers).
- Trigger point: Resolution/dereferencing of the malicious reference, causing the library to honor a remote
factoryClassLocationand attempt to load code from attacker-controlled URLs. - Why exploitation is possible: The independent JNDI-like implementation in mchange-commons-java performs remote codebase lookups and class loading by default in vulnerable versions, without deferring to the hardened JDK property
com.sun.jndi.ldap.object.trustURLCodebase, thereby bypassing core JDK hardening.
Why this happens
The underlying issue is an unsafe design pattern where untrusted or loosely validated reference data is allowed to influence remote class loading behavior.
mchange-commons-java mirrors early JNDI behavior by supporting remote factoryClassLocation URLs that can specify where factory classes should be downloaded from and instantiated. When this behavior is applied to input that can be attacker-controlled (such as hostile javax.naming.Reference objects or deserialized payloads), it effectively enables remote codebase injection and execution. This maps conceptually to CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component, because the library treats externalized reference values (including URLs and class identifiers) as trusted directives for a downstream component (the classloader and networking stack), without neutralizing or constraining them to safe, local codebases or vetted endpoints.
Potential impact
- Remote execution of attacker-supplied code within the application's JVM
- Full compromise of the affected application, including access to its data and secrets
- Lateral movement within the hosting environment or container
- Abuse of application identity to pivot to downstream services and databases
- Establishment of persistent backdoors or malware within the application runtime
General mitigation guidance
Effective mitigation focuses on limiting or eliminating remote class loading based on untrusted reference data and constraining how naming references are resolved:
- Prefer configurations and library choices where JNDI or JNDI-like functionality is disabled, especially for remote codebase resolution.
- Restrict reference handling so that
factoryClassLocationand similar parameters are either ignored or strictly limited to a known, local, and vetted set of classes or packages. - Treat all
javax.naming.Referenceinputs and serialized objects as untrusted; design APIs to avoid passing raw, externally sourced references into internal resolution mechanisms. - Adopt a strict class loading model that disallows dynamic loading from arbitrary URLs or codebases at runtime, especially in server-side applications.
- Apply least-privilege to the runtime environment, limiting network egress, filesystem access, and permissions so that even if a dereference occurs, the ability to fetch and persist malicious code is constrained.
- Centralize configuration for naming and connection management so that only trusted, statically defined references are used in production.
How teams detect issues like this
Detection can focus on both code-level patterns and runtime behavior:
- Static analysis: Search for usage of mchange-commons-java JNDI-like APIs, reference resolution utilities, or code paths that interpret
factoryClassLocationor similar fields. Flag any code that passes external or deserialized reference data into these APIs. - Code review signals: Look for:
- Custom integration code between c3p0/mchange-commons-java and naming services
- Invocation of methods that resolve
javax.naming.Referenceobjects - Dynamic URLs or external configuration values that influence class loading decisions
- Policy enforcement: Define secure coding standards prohibiting remote class loading from arbitrary URLs and requiring that all JNDI or JNDI-like usage be reviewed and justified.
- Runtime monitoring: Monitor for unusual outbound network connections originating from the JVM to unexpected hosts or protocols that coincide with reference resolution or connection pool initialization.

