Denial of Service in docx4j-core via Cyclic Style Inheritance
The docx4j-core library is vulnerable to a stack exhaustion denial-of-service attack due to missing cycle detection in the OpenXML style resolution process.
The docx4j-core library, specifically versions up to 11.5.13, contains a vulnerability in the PropertyResolver class that leads to a java.lang.StackOverflowError when parsing WordprocessingML documents. The issue stems from the library's recursive processing of the w:basedOn style inheritance chain without implementing cycle detection. By crafting a DOCX file with cyclic style references, such as Style A inheriting from Style B and Style B inheriting from Style A, an attacker can induce unbounded recursion. This attack pattern triggers immediate thread-stack exhaustion upon processing, which can lead to service degradation or process crashes in server-side applications that utilize docx4j for document transformation, conversion, or content extraction. Because the exploit relies on standard OOXML structure, it often bypasses conventional signature-based file scanners and endpoint security controls.
Attack Chain
- Attacker prepares a malicious WordprocessingML (.docx) file containing custom XML styles.
- Within the document settings, the attacker defines Style A with a
w:basedOnattribute pointing to Style B. - The attacker defines Style B with a
w:basedOnattribute pointing back to Style A, creating a circular reference. - The malicious file is uploaded to a target server-side application (e.g., document converter, web portal, or email processor).
- The target application passes the document to the vulnerable
docx4j-corelibrary for rendering or property extraction. - The
PropertyResolverattempts to resolve effective styles by recursively callingfillPPrStackfor the cyclic chain. - The Java Virtual Machine terminates the processing thread due to a
java.lang.StackOverflowErrorcaused by the recursion depth. - The application worker thread crashes, potentially leading to resource exhaustion or denial of service for other users.
Impact
Successful exploitation results in a denial of service for the document processing pipeline. Observed impact includes the immediate termination of worker threads, which can lead to total service unavailability if the application lacks robust request isolation or thread management. This vulnerability primarily affects enterprise applications in sectors such as document management, legal tech, and collaborative platforms where untrusted DOCX file submission is a core feature. The impact is elevated in environments using containerized or serverless architectures where crashes may trigger frequent, costly restarts or cascading failures across internal dependencies.
Recommendation
- Upgrade
docx4j-coreto a version that includes a fix for CVE-2026-53752. - Implement input validation for uploaded files to detect cyclic
w:basedOnreferences within the XML structure of the document before passing them to the rendering engine. - Execute document conversion tasks within sandboxed or ephemeral environments that limit the impact of process crashes on the main application.
- Monitor application logs for
java.lang.StackOverflowErrorexceptions associated with document parsing or transformation modules.
Immediate actions
Upgrade docx4j-core dependencies to patched version
Mitigations
Isolate document parsing modules in separate worker processes
CVE-2026-53752