Blog

安全编码技术:处理 XML 数据,第 1 部分

December 10, 2017
Pieter De Cremer

可扩展标记语言 (XML) 是一种标记语言,用于以一种易于机器处理和人类可读的格式对文档进行编码。但是,这种常用的格式包含多种安全漏洞。在第一篇与 XML 相关的博客文章中,我将解释使用架构安全处理 XML 文档的基础知识。

OWASP 将与 XML 和 XML 架构相关的不同漏洞分为两类。

XML 文档格式不正确

格式错误的 XML 文档是指不符合 W3C XML 规范的文档。导致文档格式错误的一些示例包括删除结尾标签、更改不同元素的顺序或使用禁用字符。所有这些错误都应导致致命错误,并且不应对文档进行任何额外处理。

为了避免由格式错误的文档导致的漏洞,您应该使用经过良好测试的 XML 解析器,该解析器遵循 W3C 规范,处理格式错误的文档的时间不会显著延长。

无效的 XML 文档

无效的 XML 文档格式正确,但包含意外值。在这里,攻击者可以利用未正确定义 XML 架构的应用程序来识别文档是否有效。以下是文档的简单示例,如果验证不正确,可能会产生意想不到的后果。

将交易存储在 XML 数据中的网络商店:

<purchase></purchase>
<id>123</id>
<price>200</price>

而且用户只能控制该<id>值。这样,如果没有正确的对策,攻击者就有可能输入这样的内容:</id>

<purchase></purchase>
<id>123</id>
<price>0</price>
<id></id>
<price>200</price>

如果处理此文档的解析器只读取<id>和<price>标签的第一个实例,这将导致不想要的结果</price></id>。

也可能是架构不够严格,或者其他输入验证不足,因此可以在意想不到的地方输入负数、特殊小数(如 NaN 或 Infinity)或超大值,从而导致类似的意外行为。

应通过定义精确且限制性的 XML 架构来避免与无效 XML 文档相关的漏洞,以避免数据验证不当的问题。

下一篇博客文章我们将介绍一些针对XML文档的更高级的攻击,例如巨型有效载荷和令人担忧的OWASP前十名第四名XXE。

同时,您可以磨练或挑战自己在 XML 输入验证方面的技能 在我们的门户网站上。

XML 和 XML 架构的规范包括多个安全漏洞。同时,这些规范提供了保护 XML 应用程序所需的工具。尽管我们使用 XML 架构来定义 XML 文档的安全性,但它们仍可用于执行各种攻击:文件检索、服务器端请求伪造、端口扫描或暴力破解。

https://www.owasp.org/index.php/XML_Security_Cheat_Sheet

标语

Govern AI-driven development before it ships

Measure AI-assisted risk, enforce secure coding policy at commit, and accelerate secure delivery across your SDLC.

book a demo
标语

Explore more blogs

Lorem Issum diam quis eim leboutis ein selerisque lobortis sepitis beelrisque lobortis sepitis celerisque lobortis celeriskue filmentis celeriskue filmentis celeriskue diam

browse all
Case Study
Filter Label
This is some text inside of a div block.

Supercharged Security Awareness: How Tournaments are Inspiring Developers at Erste Group

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique. Duis cursus, mi quis viverra ornare, eros dolor interdum nulla, ut commodo diam libero vitae erat. Aenean faucibus nibh et justo cursus id rutrum lorem imperdiet. Nunc ut sem vitae risus tristique posuere.

Learn More
Case Study
Filter Label
This is some text inside of a div block.

Security as culture: How Blue Prism cultivates world-class secure developers

Learn how Blue Prism, the global leader in intelligent automation for the enterprise, used Secure Code Warrior's agile learning platform to create a security-first culture with their developers, achieve their business goals, and ship secure code at speed

Learn More
Case Study
Filter Label
This is some text inside of a div block.

One Culture of Security: How Sage built their security champions program with agile secure code learning

Discover how Sage enhanced security with a flexible, relationship-focused approach, creating 200+ security champions and achieving measurable risk reduction.

Learn More
Blog
Filter Label
This is some text inside of a div block.

Are you a CISO or Engineering Leader worried about the Security and Cost of LLM code generation?

Review the SCW AI Trust Index, our proprietary LLM benchmarking data, before going all-in on an AI model.

Learn More
Blog
Filter Label
This is some text inside of a div block.

Enabler 6: Regular Reporting to Leadership

Executive buy-in doesn't sustain itself. Enabler 6 shows how regular reporting keeps leadership engaged, informed, and invested in program success.

Learn More
Blog
Filter Label
This is some text inside of a div block.

The Future of AI Software Governance Is Built on Strong Partnerships

Discover why Secure Code Warrior is becoming a channel-first company and how trusted partners help organizations adopt AI Software Governance securely and at scale.

Learn More

Secure AI-driven development before it ships

See developer risk, enforce policy, and prevent vulnerabilities across your software development lifecycle.

Book a demo