Vulnerability Summary
- Vulnerability Name: Apache Tika XFA XML External Entity (XXE) Vulnerability
- CVE ID: CVE-2025-66516
- Severity: High
- CVSS Score: High (as assessed by Apache/NVD)
- Vulnerability Type: XML External Entity (XXE)
- Affected Component: Apache Tika PDF parsing (XFA / AcroForm handling)
- Attack Vector: Remote (malicious PDF upload)
- Attack Complexity: Low
- Privileges Required: None
- User Interaction: None (server-side parsing)
- Exploit Availability: Public proof-of-concept released
- Patch Available: Yes
Overview
Apache Tika has addressed a high-severity security issue involving the processing of XFA (XML Forms Architecture) content embedded in PDF files. The vulnerability allows a specially crafted PDF to trigger unsafe XML parsing behavior when processed by Tika, leading to an XML External Entity (XXE) condition.
In practical terms, this means an attacker can upload or submit a malicious PDF to an application that uses Apache Tika for content extraction and cause the server to read sensitive local files or attempt outbound network connections. Because Tika is commonly used in automated ingestion pipelines, search platforms, document management systems, and data indexing services, the exposure can be significant.
This issue is especially serious because exploitation does not require authentication, elevated privileges, or user interaction.
Security Impact
If successfully exploited, the vulnerability can be used to:
- Read sensitive files from the server file system
- Access environment variables and credentials
- Trigger outbound network requests (out-of-band XXE)
- Leak cloud metadata or internal service data
- Serve as an entry point for deeper compromise
Any application that automatically parses untrusted PDF files using Apache Tika is potentially at risk until patched or mitigated.
Official Patch Information (Primary Recommendation)
The Apache Tika project has released Apache Tika version 3.2.2, which fixes the vulnerability.
Required Action
Upgrade both of the following components:
tika-coretika-parser-pdf-module
Minimum secure version: 3.2.2
Important Clarification
Upgrading only the PDF parser module is not sufficient. The underlying issue exists in shared logic within tika-core, which means both components must be upgraded together.
Verification
After upgrading, confirm your dependency tree includes:
tika-core:3.2.2
Official Patch Reference
Apache Tika release and patch information is available here:
Apache Tika Official Releases
https://tika.apache.org/download.html
This is the authoritative source for the patched version.
Mitigation Options When Patching Is Not Immediately Possible
In some environments, Apache Tika is bundled within third-party software or cannot be upgraded quickly. In such cases, the following mitigations can significantly reduce risk.
Mitigation Option 1: Disable PDF Parsing Entirely
This is the most effective temporary mitigation.
By instructing Tika to skip PDF files, the vulnerable code path is completely removed.
Configuration Example (tika-config.xml)
<?xml version="1.0" encoding="UTF-8"?>
<properties>
<parsers>
<parser class="org.apache.tika.parser.DefaultParser">
<mime-exclude>application/pdf</mime-exclude>
</parser>
<parser class="org.apache.tika.parser.EmptyParser">
<mime>application/pdf</mime>
</parser>
</parsers>
</properties>
Result
- PDFs are ignored entirely
- No metadata or text is extracted
- The exploit vector is fully blocked
This option may impact functionality but provides strong protection.
Mitigation Option 2: Pre-Validate PDF Files
PDFs can be screened before they reach Apache Tika.
Approach
- Use lightweight tools such as:
qpdfpdfid.py
- Inspect PDFs for:
- XFA structures
- AcroForm content
Rule
Reject PDFs containing XFA forms before passing them to Tika.
This significantly reduces the attack surface but may block legitimate PDFs with advanced forms.
Mitigation Option 3: Network Isolation
Many XXE attacks rely on outbound connections to exfiltrate data.
Mitigation
Apply strict outbound network controls on systems running Tika:
- Block HTTP, HTTPS, and FTP egress where possible
Limitation
This reduces data exfiltration risk but does not address the root vulnerability.
Secure Configuration: Disable XFA Without Disabling PDF Parsing
If your application requires PDF text extraction, Apache Tika allows XFA and AcroForm parsing to be disabled explicitly, which neutralizes the vulnerable behavior while preserving normal PDF processing.
Configuration via tika-config.xml (Recommended)
<?xml version="1.0" encoding="UTF-8"?>
<properties>
<parsers>
<parser class="org.apache.tika.parser.pdf.PDFParser">
<params>
<param name="extractAcroFormContent" type="bool">false</param>
<param name="ifXFAExtractOnlyXFA" type="bool">false</param>
<param name="extractAnnotationText" type="bool">false</param>
</params>
</parser>
</parsers>
</properties>
Why This Works
The vulnerability is triggered when Tika processes the XFA XML embedded in a PDF. Disabling AcroForm and XFA extraction prevents that parsing step entirely.
Programmatic Configuration (Java Applications)
import org.apache.tika.parser.pdf.PDFParserConfig;
import org.apache.tika.parser.ParseContext;
PDFParserConfig pdfConfig = new PDFParserConfig();
pdfConfig.setExtractAcroFormContent(false);
pdfConfig.setIfXFAExtractOnlyXFA(false);
ParseContext context = new ParseContext();
context.set(PDFParserConfig.class, pdfConfig);
Ensure this configuration is applied consistently across all parsing operations.
Verifying That Protections Are Working
- Obtain or create a PDF containing an XFA form.
- Parse it using your updated configuration.
- Review the output:
- Before fix: XFA or form data appears in output
- After fix: Main PDF content is extracted, form data is ignored
Indicators of Compromise (Detection Guidance)
Network-Based Indicators
Monitor for unexpected outbound connections initiated by the Tika process:
- Requests to:
169.254.169.254(cloud metadata)10.0.0.0/8,192.168.0.0/16127.0.0.1
- Unusual ports such as 8080, 8888, or 1337
- DNS lookups to domains commonly used for OOB testing:
*.burpcollaborator.net*.oast.pro*.interact.sh
Log-Based Indicators
Look for XML parsing errors in application logs:
EntityExpansionExceptionSAXParseExceptionDOCTYPEENTITYXFA
Example search pattern:
(message="*EntityExpansionException*" OR message="*DOCTYPE*" OR message="*XFA*")
AND (message="*SAXParseException*" OR level=ERROR)
File-Based Indicators
Malicious PDFs often contain:
/XFAdictionaries- Embedded
<!DOCTYPE>declarations - Attempts by the Tika process to read:
/etc/passwd/etc/shadowC:\Windows\win.ini~/.aws/credentials/proc/self/environ
Final Takeaway
Upgrading to Apache Tika 3.2.2 or later is the safest and most complete fix for CVE-2025-66516. Where immediate patching is not feasible, disabling XFA processing or restricting PDF parsing provides effective interim protection. Continuous monitoring of outbound traffic and application logs is essential to detect exploitation attempts early.
