CVE-2026-42440: Apache OpenNLP: OOM DoS via Unbounded Array Allocation in AbstractModelReader
OOM Denial of Service via Unbounded Array Allocation in Apache OpenNLP AbstractModelReader
Versions Affected:
before 1.9.5
before 2.5.9
before 3.0.0-M3
Description:
The AbstractModelReader methods getOutcomes(), getOutcomePatterns(), and getPredicates() each read a 32-bit signed integer count field from a binary model stream and pass that value directly to an array allocation (new String[numOutcomes], new int[numOCTypes][], new String[NUM_PREDS]) without validating that the value is non-negative or within a reasonable bound. The count is therefore fully attacker-controlled when the model file originates from an untrusted source.
A crafted .bin model file in which any of these count fields is set to Integer.MAX_VALUE (or any value large enough to exhaust the available heap) triggers an OutOfMemoryError at the array allocation itself, before the corresponding label or pattern data is consumed from the stream. The error occurs very early in deserialization: for a GIS model, getOutcomes() is reached after only the model-type string, the correction constant, and the correction parameter have been read; so the attacker pays no meaningful size cost to weaponize a payload, and a single small file can crash a JVM that loads it. Any code path that deserializes a .bin model is affected, including direct use of GenericModelReader and any higher-level component that delegates to it during model load.
The practical impact is denial of service against processes that load model files from untrusted or semi-trusted origins.
Mitigation:
* 2.x users should upgrade to 2.5.9.
* 3.x users should upgrade to 3.0.0-M3.
Note: The fix introduces an upper bound on each of the three count fields, checked before array allocation; counts that are negative or exceed the bound cause an IllegalArgumentException to be thrown and the read to fail fast with no large allocation. The default bound is 10,000,000, which is well above the entry counts of legitimate OpenNLP models but far below any value that would threaten heap exhaustion. Deployments that legitimately need to load models with more entries than the default can raise the limit at JVM startup by setting the OPENNLP_MAX_ENTRIES system property to the desired positive integer (e.g. -DOPENNLP_MAX_ENTRIES=50000000); invalid or non-positive values fall back to the default.
Users who cannot upgrade immediately should treat all .bin model files as untrusted input unless their provenance is verified, and should avoid loading models supplied by end users or fetched from third-party repositories without integrity checks.
Security readout for executives and security teams
Plain-English summary
Apache OpenNLP can crash when it loads a malicious binary model file. The file can declare an enormous number of entries, causing the Java process to exhaust memory before substantial file content is read. Business impact is service unavailability, not disclosed data theft or modification.
Executive priority
Prioritize remediation for internet-facing or business-critical services that automatically load externally sourced models. Treat isolated deployments using only controlled, integrity-verified models as lower immediate exposure, but still upgrade through normal security change procedures. A successful attack can terminate the JVM and disrupt dependent services.
Technical view
AbstractModelReader passes attacker-controlled signed 32-bit counts from a .bin stream directly into array allocations in getOutcomes(), getOutcomePatterns(), and getPredicates(). Large counts can trigger OutOfMemoryError early during deserialization. The reported affected versions are before 1.9.5, before 2.5.9, and before 3.0.0-M3.
Likely exposure
Exposure is highest where affected OpenNLP applications load .bin models uploaded by users, obtained from third-party repositories, or otherwise lacking verified provenance and integrity. Merely having the library installed does not establish reachability; an attacker must influence a model that the process loads.
Exploitation context
The supplied record is not listed in KEV and provides no evidence of active exploitation. Exploitation requires an application path that loads an attacker-influenced model. A small crafted file may exhaust JVM memory because allocation occurs before the corresponding model data is consumed.
Researcher notes
The weakness maps to CWE-770 and CWE-789. The fix reportedly validates all three count fields before allocation, rejecting negative or excessive values. Its default maximum is 10,000,000 entries and can be changed through OPENNLP_MAX_ENTRIES. The supplied evidence does not establish exploit availability, observed attacks, or affected downstream products.
Mitigation direction
Upgrade OpenNLP 2.x deployments to 2.5.9.
Upgrade OpenNLP 3.x deployments to 3.0.0-M3.
For other affected release lines, confirm the supported fixed version in Apache guidance.
Until upgraded, reject user-supplied models and require verified provenance and integrity for every .bin file.
Do not raise OPENNLP_MAX_ENTRIES unless legitimate model requirements are documented and memory risk is assessed.
Validation and detection
Inventory applications using org.apache.opennlp:opennlp-tools and record their exact versions.
Trace whether direct or higher-level model readers can load externally influenced .bin files.
Confirm all deployed versions meet the applicable fixed-version threshold.
Verify model repositories, upload paths, integrity controls, and provenance requirements.
After upgrading, confirm oversized or negative counts fail before large memory allocation.
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-770: 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.
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.
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.
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-770 · source CWE mapping
Allocation of Resources Without Limits or Throttling
Allocation of Resources Without Limits or Throttling represents a recurring weakness pattern that can create exploitable paths when design, validation, or implementation controls are missing.
Memory Allocation with Excessive Size Value represents a recurring weakness pattern that can create exploitable paths when design, validation, or implementation controls are missing.