This product is not supported for your selected Datadog site. ().
이 페이지는 아직 영어로 제공되지 않습니다. 번역 작업 중입니다.
현재 번역 프로젝트에 대한 질문이나 피드백이 있으신 경우 언제든지 연락주시기 바랍니다.

Metadata

ID: python-security/xxe-injection

Language: Python

Severity: Warning

Category: Security

CWE: 611

Description

This rule detects potential XML External Entity (XXE) vulnerabilities in Python code. XXE attacks occur when an application parses XML input containing external entity references, which can lead to data exposure, denial of service, or other security issues. The vulnerability arises when untrusted XML content is processed without proper configuration to disable external entity resolution.

To avoid this vulnerability, always use safe XML parsing practices. For example, avoid parsing XML from untrusted sources directly with default settings, such as ElementTree.parse(content). Instead, parse XML from trusted file paths or configure the parser to disable external entity resolution. Using libraries or methods that do not process external entities by default is also recommended.

Non-Compliant Code Examples

import xml
import xml.etree import ElementTree

tree = ElementTree.parse(f"${something}")
import xml

tree = xml.etree.ElementTree.parse(content)
import xml
import xml.etree import ElementTree

tree = ElementTree.parse(content)

Compliant Code Examples

import xml
import xml.etree import ElementTree

tree = ElementTree.parse('myfile.xml')
tree = ElementTree.parse("myfile.xml")
https://static.datadoghq.com/static/images/logos/github_avatar.svg https://static.datadoghq.com/static/images/logos/vscode_avatar.svg jetbrains

원활한 통합. Datadog Code Security를 경험해 보세요