Apache OpenNLP: OOM DoS via Unbounded Array Allocation in AbstractModelReader
Apache Software Foundation Apache OpenNLP
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| org.apache.opennlp:opennlp-tools Maven |
|
|
Apache Software Foundation Apache OpenNLP
| Product | Affected | Fixed in |
|---|---|---|
| org.apache.opennlp:opennlp-tools Maven |
|
|
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.
From the CVE record · apache
Apache OpenNLP AbstractModelReader allocates arrays using unchecked counts from binary model files. An attacker who can supply a crafted .bin model file can exhaust the JVM heap and crash a process when it loads the file; the attack requires the process to load the file, but no user interaction is described.
Check deployments using Maven org.apache.opennlp:opennlp-tools versions before 1.9.5, 2.0.0 through versions before 2.5.9, or 3.0.0-M1 through versions before 3.0.0-M3.