CVE-2026-42027: Apache OpenNLP: Arbitrary Class Instantiation via Model Manifest in ExtensionLoader
Arbitrary Class Instantiation via Model Manifest in Apache OpenNLP ExtensionLoader
Versions Affected: before 1.9.5, before 2.5.9, before 3.0.0-M3
Description:
The ExtensionLoader.instantiateExtension(Class, String) method loads a class by its fully-qualified name via Class.forName() and invokes its no-arg constructor, with the class name sourced from the manifest.properties entry of a model archive. The existing isAssignableFrom check correctly rejects classes that are not subtypes of the expected extension interface (BaseToolFactory for factory=, ArtifactSerializer for serializer-class-*), but the check runs after Class.forName() has already loaded and initialized the named class.
Class.forName() with default initialization semantics executes the target class's static initializer before returning, so an attacker who can supply a crafted model archive can cause the static initializer of any class on the classpath to run during model loading, regardless of whether that class passes the subsequent type check.
Exploitation requires a class with attacker-useful side effects in its static initializer (for example, JNDI lookup, outbound network I/O, or filesystem access) to be present on the classpath, so this is not a drop-in remote code execution; however, the attack surface grows as third-party model distribution becomes more common (community model repositories, Hugging Face-style sharing), where users routinely load model files from origins they do not control. A secondary, narrower vector affects deployments that ship legitimate BaseToolFactory or ArtifactSerializer subclasses with side-effecting no-arg constructors: a malicious manifest can name such a class and force its constructor to run during model load.
Mitigation:
* 2.x users should upgrade to 2.5.9.
* 3.x users should upgrade to 3.0.0-M3.
Note: The fix introduces a package-prefix allowlist that is consulted before Class.forName() is invoked, so the static initializer of a disallowed class is never executed. Classes under the opennlp. prefix remain permitted by default. Deployments that load models referencing factories or serializers outside opennlp.* must opt those packages in, either programmatically via ExtensionLoader.registerAllowedPackage(String) before the first model load, or by setting the OPENNLP_EXT_ALLOWED_PACKAGES system property to a comma-separated list of allowed package prefixes.
Users who cannot upgrade immediately should ensure that all model files are sourced from trusted origins and should audit their classpath for classes with side-effecting static initializers or constructors, particularly any that perform JNDI lookups, network requests, or filesystem operations during class initialization.
Security readout for executives and security teams
Plain-English summary
A malicious OpenNLP model file can make the application initialize unexpected Java classes already present on its classpath. Those classes may perform network, filesystem, or JNDI actions during initialization. Serious impact is possible, but exploitation depends on a suitable side-effecting class being available, so this is not automatic remote code execution.
Executive priority
Prioritize rapid remediation where services load third-party or user-controlled models. Patch other affected deployments promptly because a compromised model supply chain could turn existing classpath components into high-impact behavior. Pair upgrades with model-source governance and a narrow extension allowlist.
Technical view
ExtensionLoader obtains class names from a model archive’s manifest and calls Class.forName() before verifying the class implements the expected interface. Class loading therefore executes static initializers even when the later type check rejects the class. Valid extension subclasses with side-effecting no-argument constructors provide a narrower secondary vector.
Likely exposure
Highest risk applies to applications using affected OpenNLP versions that load model archives from community repositories, external users, or other uncontrolled sources. Exposure and impact depend on the application classpath containing classes with useful initialization side effects. Environments accepting only internally controlled models have lower practical exposure, but remain vulnerable if trust controls fail.
Exploitation context
An attacker must supply or influence a model archive and reference a useful class already present on the target classpath. The supplied sources do not establish active exploitation, and the CVE is not listed as KEV. Absence from KEV does not prove exploitation has never occurred.
Researcher notes
The security boundary failure is ordering: initialization occurs before assignability validation. The fix adds a package-prefix allowlist consulted before Class.forName(); opennlp.* remains allowed by default. Custom factories or serializers outside that namespace require explicit registration or the OPENNLP_EXT_ALLOWED_PACKAGES property. Assess reachable model-loading paths and the complete runtime classpath together.
Mitigation direction
Upgrade OpenNLP 2.x to 2.5.9 and 3.x to 3.0.0-M3 or later.
Move deployments before 1.9.5 to version 1.9.5 or a later supported release.
Until upgraded, accept model archives only from authenticated, trusted origins.
Audit the classpath for static initializers or constructors performing JNDI, network, or filesystem operations.
Allow custom extension package prefixes only when operationally required and explicitly trusted.
Validation and detection
Inventory deployed OpenNLP versions, including resolved org.apache.opennlp:opennlp-tools dependencies.
Trace every model archive source and identify paths accepting externally supplied or community models.
Inspect model manifests for factory and serializer class references, especially packages outside opennlp.*.
Confirm upgraded deployments reject non-allowlisted packages before their classes initialize.
Monitor model-loading activity for unexpected JNDI, outbound network, or filesystem behavior.
Generated from the cited source records. This long-tail analysis has not been individually reviewed by a named human.
Potential ATT&CK relevance
Conservative CVE-to-ATT&CK context
These mappings and lookup hints may be relevant to the vulnerability behavior, CWE, affected product, or exposure path. Glexia-inferred context is not an official MITRE, ATT&CK, CWE, or CVE Program mapping.
ATT&CK lookup starting points
Use these exact CWE pages and searches to review the Glexia ATT&CK library from this CVE's weakness and description context.
cwe · low confidence lookup
CWE-470: Exact CWE lookup
Use the exact CWE identifier as the starting point before reviewing related ATT&CK behavior. Open the exact CWE lookup page first, then review the ATT&CK searches from that MITRE weakness context. This is a Glexia lookup hint, not an official ATT&CK mapping.
Code execution and unsafe deserialization weaknesses often justify reviewing execution behavior and process telemetry. Open the exact CWE lookup page first, then review the ATT&CK searches from that MITRE weakness context. This is a Glexia lookup hint, not an official ATT&CK mapping.
The CVE wording references code or command execution, so execution technique review may help defensive triage. This is a Glexia inferred lookup path, not an official MITRE, ATT&CK, or CVE Program mapping.
These fields come from the CVE record and ADP containers, not from Glexia's Take. They preserve time-varying source decisions such as CISA SSVC, KEV status, CVSS metrics, and provider references.
2CVSS vectors
5Timeline events
3ADP providers
6Source links
SSVC decision data
CISA-ADPCISA Coordinator
Timestamp
Version
2.0.3
Exploitation: noneAutomatable: yesTechnical Impact: total
CVSS vector scores
2 official scores
We collect every scored CVSS vector available in the official CNA and ADP containers. When more than one version is present, the table keeps the source vectors side by side instead of collapsing them into the highest score.
CWE links open Glexia weakness intelligence pages with official CWE context, developer remediation guidance, and related CVE mappings.
CWE-470 · source CWE mapping
Use of Externally-Controlled Input to Select Classes or Code ('Unsafe Reflection')
Use of Externally-Controlled Input to Select Classes or Code ('Unsafe Reflection') represents a recurring weakness pattern that can create exploitable paths when design, validation, or implementation controls are missing.
Deserialization of Untrusted Data represents a recurring weakness pattern that can create exploitable paths when design, validation, or implementation controls are missing.