CVE-2026-42027: CWE-470 Use of Externally-Controlled Input to Select Classes or Code ('Unsafe Reflection') in Apache Software Foundation Apache OpenNLP
CVE-2026-42027 is a critical vulnerability in Apache OpenNLP versions before 2.5.9 and before 3.0.0-M3. It involves unsafe reflection where the ExtensionLoader.instantiateExtension method loads classes by name from a model archive manifest before verifying their type, causing static initializers of arbitrary classes on the classpath to execute. This can lead to unintended side effects if those classes have static initializers performing actions like network or filesystem access. Exploitation requires attacker-controlled model archives and suitable classes present on the classpath. The vulnerability is mitigated in fixed versions by introducing a package-prefix allowlist to prevent loading unauthorized classes.
AI Analysis
Technical Summary
The vulnerability arises from the ExtensionLoader.instantiateExtension(Class, String) method in Apache OpenNLP, which uses Class.forName() to load a class specified by the manifest.properties entry of a model archive. Although a type check is performed after loading, the class is already initialized, executing its static initializer. An attacker supplying a crafted model archive can cause any class on the classpath to have its static initializer run during model loading, potentially triggering side effects such as JNDI lookups, network I/O, or filesystem access. This is not direct remote code execution but can be leveraged if suitable classes with side-effecting static initializers exist. The fix, introduced in versions 2.5.9 and 3.0.0-M3, adds a package-prefix allowlist checked before class loading to block unauthorized classes. Users must upgrade or restrict model sources and audit their environment.
Potential Impact
Successful exploitation allows an attacker who can supply a malicious model archive to trigger the static initializer of any class on the classpath during model loading. This can lead to side effects such as network requests, filesystem access, or other actions performed by those static initializers, potentially compromising confidentiality, integrity, and availability. The vulnerability has a CVSS score of 9.8 (critical), indicating high impact with network attack vector, no privileges or user interaction required, and full confidentiality, integrity, and availability impact. However, exploitation depends on the presence of classes with exploitable static initializers on the classpath and attacker control over model archives.
Mitigation Recommendations
A fix is available: users of Apache OpenNLP 2.x should upgrade to version 2.5.9 or later, and users of 3.x should upgrade to 3.0.0-M3 or later. The fix implements a package-prefix allowlist to prevent loading classes outside approved packages, blocking execution of unauthorized static initializers. Deployments that load models referencing classes outside the default 'opennlp.' package must explicitly allow those packages via ExtensionLoader.registerAllowedPackage(String) or the OPENNLP_EXT_ALLOWED_PACKAGES system property before loading models. Users unable to upgrade immediately should ensure all model files come from trusted sources and audit their classpath for classes with side-effecting static initializers or constructors, especially those performing JNDI lookups, network, or filesystem operations during initialization.
CVE-2026-42027: CWE-470 Use of Externally-Controlled Input to Select Classes or Code ('Unsafe Reflection') in Apache Software Foundation Apache OpenNLP
Description
CVE-2026-42027 is a critical vulnerability in Apache OpenNLP versions before 2.5.9 and before 3.0.0-M3. It involves unsafe reflection where the ExtensionLoader.instantiateExtension method loads classes by name from a model archive manifest before verifying their type, causing static initializers of arbitrary classes on the classpath to execute. This can lead to unintended side effects if those classes have static initializers performing actions like network or filesystem access. Exploitation requires attacker-controlled model archives and suitable classes present on the classpath. The vulnerability is mitigated in fixed versions by introducing a package-prefix allowlist to prevent loading unauthorized classes.
CVSS v3.1
Score 9.8critical
Affected software
Weaknesses
AI-Powered Analysis
Machine-generated threat intelligence
Technical Analysis
The vulnerability arises from the ExtensionLoader.instantiateExtension(Class, String) method in Apache OpenNLP, which uses Class.forName() to load a class specified by the manifest.properties entry of a model archive. Although a type check is performed after loading, the class is already initialized, executing its static initializer. An attacker supplying a crafted model archive can cause any class on the classpath to have its static initializer run during model loading, potentially triggering side effects such as JNDI lookups, network I/O, or filesystem access. This is not direct remote code execution but can be leveraged if suitable classes with side-effecting static initializers exist. The fix, introduced in versions 2.5.9 and 3.0.0-M3, adds a package-prefix allowlist checked before class loading to block unauthorized classes. Users must upgrade or restrict model sources and audit their environment.
Potential Impact
Successful exploitation allows an attacker who can supply a malicious model archive to trigger the static initializer of any class on the classpath during model loading. This can lead to side effects such as network requests, filesystem access, or other actions performed by those static initializers, potentially compromising confidentiality, integrity, and availability. The vulnerability has a CVSS score of 9.8 (critical), indicating high impact with network attack vector, no privileges or user interaction required, and full confidentiality, integrity, and availability impact. However, exploitation depends on the presence of classes with exploitable static initializers on the classpath and attacker control over model archives.
Mitigation Recommendations
A fix is available: users of Apache OpenNLP 2.x should upgrade to version 2.5.9 or later, and users of 3.x should upgrade to 3.0.0-M3 or later. The fix implements a package-prefix allowlist to prevent loading classes outside approved packages, blocking execution of unauthorized static initializers. Deployments that load models referencing classes outside the default 'opennlp.' package must explicitly allow those packages via ExtensionLoader.registerAllowedPackage(String) or the OPENNLP_EXT_ALLOWED_PACKAGES system property before loading models. Users unable to upgrade immediately should ensure all model files come from trusted sources and audit their classpath for classes with side-effecting static initializers or constructors, especially those performing JNDI lookups, network, or filesystem operations during initialization.
Technical Details
- Data Version
- 5.2
- Assigner Short Name
- apache
- Date Reserved
- 2026-04-23T14:21:25.317Z
- Cvss Version
- null
- State
- PUBLISHED
- Remediation Level
- null
Threat ID: 69f8d216cbff5d8610397044
Added to database: 5/4/2026, 5:06:30 PM
Last enriched: 5/12/2026, 6:24:25 AM
Last updated: 6/19/2026, 3:45:00 AM
Views: 47
Community Reviews
0 reviewsCrowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.
Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.
Actions
Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.
Need more coverage?
Upgrade to Pro Console for AI refresh and higher limits.
For incident response and remediation, OffSeq services can help resolve threats faster.
Latest Threats
Check if your credentials are on the dark web
Instant breach scanning across billions of leaked records. Free tier available.