CVE-2026-40682: Apache OpenNLP: XXE via Dictionary Parsing in DictionaryEntryPersistor
XML External Entity (XXE) via Unsanitized Dictionary Parsing in Apache OpenNLP DictionaryEntryPersistor
Versions Affected: before 2.5.9, before 3.0.0-M3
Description: The DictionaryEntryPersistor class initializes a static SAXParserFactory at class-load time without enabling FEATURESECUREPROCESSING or disabling DTD processing. When create(InputStream, EntryInserter) is invoked, the only feature set on the XMLReader is namespace support — external entity resolution and DOCTYPE declarations remain fully enabled. An attacker who can supply a crafted dictionary file (e.g., a stop-word list or domain dictionary) containing a malicious DOCTYPE declaration can trigger local file disclosure via file:// entity references or server-side request forgery via http:// entity references during SAX parsing, before the application processes a single dictionary entry. This is inconsistent with the project's own XmlUtil.createSaxParser() helper, which correctly sets FEATURESECUREPROCESSING and disallow-doctype-decl and is used by all other XML parsing paths in the codebase. The public Dictionary(InputStream) constructor delegates directly to this method and is the documented API for loading user-supplied dictionaries, making untrusted input a realistic scenario.
Mitigation: 2.x users should upgrade to 2.5.9. 3.x users should upgrade to 3.0.0-M3. Users who cannot upgrade immediately should ensure that all dictionary files are sourced from trusted origins and should consider wrapping the Dictionary(InputStream) constructor with input validation that rejects any XML containing a DOCTYPE declaration before it reaches the parser.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
Apache OpenNLPto a version that resolves this vulnerability.Fixed in 2.5.9Patch CVE-2026-40682 - Upgrade
Upgrade
Apache OpenNLPto a version that resolves this vulnerability.Fixed in 3.0.0-M3Patch CVE-2026-40682 - Configuration
Wrap the Dictionary(InputStream) constructor usage with input validation that rejects any XML containing a DOCTYPE declaration, because XXE can be triggered during SAX parsing before any dictionary entry is processed.
Apache OpenNLP Dictionary(InputStream) / dictionary XML parsing Reject DOCTYPE declarations = reject any XML containing a DOCTYPE declaration (disallow DOCTYPE) before it reaches the parser - Compensating control
If you cannot upgrade immediately, ensure all dictionary files loaded via Apache OpenNLP Dictionary(InputStream) are sourced from trusted origins, since the Dictionary(InputStream) constructor delegates directly to DictionaryEntryPersistor SAX parsing.
Event History
Frequently Asked Questions
Which applications are realistically exposed?
Applications that load stop-word lists, domain dictionaries, or other dictionary files from an attacker-controlled source through the public Dictionary(InputStream) constructor are exposed. That constructor delegates to the vulnerable dictionary parsing path.
What must an attacker be able to do?
An attacker must be able to supply a crafted dictionary XML file containing a malicious DOCTYPE declaration. No authentication, user interaction, or network access to the target service is required by the CVSS vector.
Is the vulnerable behavior present without a special parser configuration?
Yes. The DictionaryEntryPersistor parsing path does not enable secure processing or disable DTD declarations and external entity resolution; it only enables namespace support on the XMLReader.
How can I determine whether my application is affected?
Check whether it uses Apache OpenNLP versions before 2.5.9 or before 3.0.0-M3 and calls Dictionary(InputStream) or otherwise invokes DictionaryEntryPersistor.create(InputStream, EntryInserter). Review whether any dictionary input can be influenced by untrusted users or external sources.
What is the impact if exploitation succeeds?
A malicious file:// external entity can disclose local files, while an http:// external entity can cause server-side requests. Entity processing occurs during SAX parsing before any dictionary entry is processed.