CVE-2026-42027: Apache OpenNLP arbitrary class instantiation in ExtensionLoader

CVE-2026-42027 · Severity: critical · CVSS 9.8 · Published 2026-05-04

Apache OpenNLP is a Java library used for natural language processing tasks like tokenization, part-of-speech tagging, and model loading. A flaw in its model-loading mechanism allows an attacker who supplies a malicious model archive to trigger execution of arbitrary static code initializers or constructors from any class on the application classpath. If the classpath contains utility libraries with side effects during initialization (such as JNDI lookups or network calls), an attacker can exploit those to achieve data exfiltration, denial of service, or arbitrary command execution without requiring the victim to grant special permissions.

Technologies: Apache Opennlp, org.apache.opennlp:opennlp-tools (Maven). Vendors: Apache, Maven.

Quick answers

Is CVE-2026-42027 exploited in the wild?
No. Junglewise Threat Intelligence has no report of CVE-2026-42027 being exploited in the wild.
How severe is CVE-2026-42027?
Critical severity, with a CVSS score of 9.8, published 4 May 2026.
Which products and versions are affected?
Apache Opennlp < 1.9.5, >= 2.0.0 and < 2.5.9, >= 3.0.0-M1 and < 3.0.0-M3; org.apache.opennlp:opennlp-tools (Maven) ECOSYSTEM:introduced=2.0.0,fixed=2.5.9.
Is there a fix for CVE-2026-42027?
Yes. org.apache.opennlp:opennlp-tools (Maven): upgrade to 2.5.9 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
How is CVE-2026-42027 attacked?
It is attacked over the network, in a software library.
Am I affected by CVE-2026-42027?
Check whether you run Apache Opennlp or org.apache.opennlp:opennlp-tools (Maven) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

How to fix

  • org.apache.opennlp:opennlp-tools (Maven): upgrade to 2.5.9 or later
    # set org.apache.opennlp:opennlp-tools to 2.5.9 in your pom.xml or build.gradle

Technical details

The vulnerability exists in ExtensionLoader.instantiateExtension(Class, String), which loads a class by name via Class.forName() before checking whether it conforms to the expected extension interface (BaseToolFactory or ArtifactSerializer). Class.forName() with default semantics executes the target class's static initializer immediately, even if the type check that follows rejects the class as invalid. An attacker crafting a model archive can list any classpath class in the manifest.properties file, causing its static initializer to run during model load. While this is not direct remote code execution, exploitation is practical when the classpath includes libraries performing JNDI lookups, HTTP requests, file operations, or similar side effects during class initialization. A secondary narrower attack vector targets applications with BaseToolFactory or ArtifactSerializer subclasses that have side-effecting no-argument constructors. Patches (1.9.5, 2.5.9, 3.0.0-M3) introduce a package-prefix allowlist checked before Class.forName() is invoked.

Affected products

  • Apache OpenNLP < 1.9.5, >= 2.0.0 and < 2.5.9, >= 3.0.0-M1 and < 3.0.0-M3

Identifiers

  • CVE-2026-42027
  • GHSA-cx4m-2p55-rw7j

Timeline

  • 2026-05-04: disclosed: Vulnerability published to GitHub Advisory Database and NVD
  • 2026-05-04: patched: Patches released: 1.9.5, 2.5.9, 3.0.0-M3

References

This page as Markdown. Free to reuse under CC BY 4.0 with a link back.