CVE-2026-42027
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
Description
CVSS Scores
EPSS Scores
| Probability: | |
| Percentile: |
Meta Information
Affected Vendors & Products
| 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 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.