CVE-2026-42027
Undergoing Analysis Undergoing Analysis - In Progress
Arbitrary Class Instantiation via Model Manifest in Apache OpenNLP

Publication date: 2026-05-04

Last updated on: 2026-05-06

Assigner: Apache Software Foundation

Description
Arbitrary Class Instantiation via Model Manifest in Apache OpenNLP ExtensionLoader Versions Affected: 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.
CVSS Scores
EPSS Scores
Probability:
Percentile:
Meta Information
Published
2026-05-04
Last Modified
2026-05-06
Generated
2026-05-07
AI Q&A
2026-05-05
EPSS Evaluated
2026-05-05
NVD
Affected Vendors & Products
Showing 3 associated CPEs
Vendor Product Version / Range
apache opennlp to 2.5.9 (exc)
apache opennlp 3.0.0
apache opennlp 3.0.0
Helpful Resources
Exploitability
CWE
CWE Icon
KEV
KEV Icon
CWE ID Description
CWE-470 The product uses external input with reflection to select which classes or code to use, but it does not sufficiently prevent the input from selecting improper classes or code.
Attack-Flow Graph
AI Powered Q&A
How does this vulnerability affect compliance with common standards and regulations (like GDPR, HIPAA)?:

The vulnerability allows execution of static initializers of arbitrary classes during model loading, which can lead to unintended side effects such as network I/O or filesystem access.

This behavior can increase the risk of unauthorized data access or data leakage if exploited, potentially impacting compliance with data protection regulations like GDPR or HIPAA that require strict control over data processing and access.

Organizations using affected versions should upgrade or ensure that only trusted model files are loaded and audit their classpath for classes with side-effecting initializers to mitigate risks that could lead to non-compliance.


Can you explain this vulnerability to me?

This vulnerability exists in the Apache OpenNLP ExtensionLoader.instantiateExtension method, which loads classes by name from a model archive's manifest. The method uses Class.forName() to load and initialize the class before verifying that it is a subtype of the expected interface. Because Class.forName() runs the class's static initializer immediately, an attacker who supplies a crafted model archive can trigger the static initializer of any class on the classpath during model loading.

This means that even if the class does not pass the subsequent type check, its static initializer code will have already executed. Exploitation requires the presence of a class with side effects in its static initializer (such as network calls or filesystem access) on the classpath. Additionally, a malicious manifest can force the constructor of legitimate classes with side-effecting no-arg constructors to run during model load.


How can this vulnerability impact me? :

This vulnerability can allow an attacker to execute arbitrary code indirectly by triggering static initializers of classes on the classpath that have side effects, such as performing network requests, JNDI lookups, or filesystem operations. This can lead to unauthorized actions during model loading, potentially compromising the security of the system.

The risk increases when users load model files from untrusted or third-party sources, such as community model repositories or shared model hubs, where maliciously crafted model archives could be introduced.


How can this vulnerability be detected on my network or system? Can you suggest some commands?

Detection involves auditing your classpath for classes with side-effecting static initializers or constructors, especially those performing JNDI lookups, network requests, or filesystem operations during class initialization.

Additionally, ensure that all model files are sourced from trusted origins to reduce risk.

No specific commands are provided in the available information to detect this vulnerability on your network or system.


What immediate steps should I take to mitigate this vulnerability?

Immediate mitigation steps include upgrading Apache OpenNLP to version 2.5.9 if you are using the 2.x branch, or to 3.0.0-M3 if you are using the 3.x branch.

The fix introduces a package-prefix allowlist that prevents execution of static initializers of disallowed classes. If you cannot upgrade immediately, ensure all model files come from trusted sources.

For deployments loading models referencing factories or serializers outside the opennlp.* package prefix, explicitly opt-in those packages 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.

Audit your classpath for classes with side-effecting static initializers or constructors, particularly those performing JNDI lookups, network requests, or filesystem operations during class initialization.


Ask Our AI Assistant
Need more information? Ask your question to get an AI reply (Powered by our expertise)
0/70
EPSS Chart