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
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中文网
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论