CWE-112 XML验证缺失

admin 2022年1月2日04:08:29CWE(弱点枚举)评论12 views1958字阅读6分31秒阅读模式

CWE-112 XML验证缺失

Missing XML Validation

结构: Simple

Abstraction: Base

状态: Draft

被利用可能性: unkown

基本描述

The software accepts XML from an untrusted source but does not validate the XML against the proper schema.

扩展描述

Most successful attacks begin with a violation of the programmer's assumptions. By accepting an XML document without validating it against a DTD or XML schema, the programmer leaves a door open for attackers to provide unexpected, unreasonable, or malicious input.

相关缺陷

  • cwe_Nature: ChildOf cwe_CWE_ID: 1173 cwe_View_ID: 1000 cwe_Ordinal: Primary

  • cwe_Nature: ChildOf cwe_CWE_ID: 1173 cwe_View_ID: 699 cwe_Ordinal: Primary

  • cwe_Nature: ChildOf cwe_CWE_ID: 20 cwe_View_ID: 700 cwe_Ordinal: Primary

适用平台

Language: {'cwe_Class': 'Language-Independent', 'cwe_Prevalence': 'Undetermined'}

常见的影响

范围 影响 注释
Integrity Unexpected State

可能的缓解方案

Architecture and Design

策略: Input Validation

Always validate XML input against a known XML Schema or DTD.
It is not possible for an XML parser to validate all aspects of a document's content because a parser cannot understand the complete semantics of the data. However, a parser can do a complete and thorough job of checking the document's structure and therefore guarantee to the code that processes the document that the content is well-formed.

示例代码

The following code loads and parses an XML file.

bad Java


// Read DOM

try {

...
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setValidating( false );
....
c_dom = factory.newDocumentBuilder().parse( xmlFile );

} catch(Exception ex) {

...

}

The XML file is loaded without validating it against a known XML Schema or DTD.

The following code creates a DocumentBuilder object to be used in building an XML document.

bad Java

DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
builderFactory.setNamespaceAware(true);
DocumentBuilder builder = builderFactory.newDocumentBuilder();

The DocumentBuilder object does not validate an XML document against a schema, making it possible to create an invalid XML document.

分类映射

映射的分类名 ImNode ID Fit Mapped Node Name
7 Pernicious Kingdoms Missing XML Validation
Software Fault Patterns SFP24 Tainted input to command

相关攻击模式

  • CAPEC-230
  • CAPEC-231
  • CAPEC-484
  • CAPEC-99

文章来源于互联网:scap中文网

特别标注: 本站(CN-SEC.COM)所有文章仅供技术研究,若将其信息做其他用途,由用户承担全部法律及连带责任,本站不承担任何法律及连带责任,请遵守中华人民共和国安全法.
  • 我的微信
  • 微信扫一扫
  • weinxin
  • 我的微信公众号
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2022年1月2日04:08:29
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                  CWE-112 XML验证缺失 http://cn-sec.com/archives/612921.html

发表评论

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: