XMLを扱うモジュール群
*********************

**ソースコード:** Lib/xml/

======================================================================

PythonのXMLを扱うインターフェースは "xml" パッケージにまとめられていま
す。

注釈:

  If you need to parse untrusted or unauthenticated data, see XML
  security.

注意すべき重要な点として、 "xml" パッケージのモジュールは SAX に対応し
た XML パーザが少なくとも一つ利用可能でなければなりません。Expat パー
ザが Python に取り込まれているので、 "xml.parsers.expat" モジュールは
常に利用できます。

"xml.dom" および "xml.sax" パッケージのドキュメントは Python による
DOM および SAX インターフェースへのバインディングに関する定義です。

XML に関連するサブモジュール:

* "xml.etree.ElementTree": ElementTree API、シンプルで軽量な XML プロ
  セッサ

* "xml.dom": DOM API の定義

* "xml.dom.minidom": 最小限の DOM の実装

* "xml.dom.pulldom": 部分的な DOM ツリー構築のサポート

* "xml.sax": SAX2 基底クラスと便利関数群

* "xml.parsers.expat": Expat parser バインディング


XML security
============

An attacker can abuse XML features to carry out denial of service
attacks, access local files, generate network connections to other
machines, or circumvent firewalls when attacker-controlled XML is
being parsed, in Python or elsewhere.

The built-in XML parsers of Python rely on the library libexpat,
commonly called Expat, for parsing XML.

By default, Expat itself does not access local files or create network
connections.

Expat versions lower than 2.7.2 may be vulnerable to the "billion
laughs", "quadratic blowup" and "large tokens" vulnerabilities, or to
disproportional use of dynamic memory. Python bundles a copy of Expat,
and whether Python uses the bundled or a system-wide Expat, depends on
how the Python interpreter "has been configured" in your environment.
Python may be vulnerable if it uses such older versions of Expat.
Check "pyexpat.EXPAT_VERSION".

"xmlrpc" is **vulnerable** to the "decompression bomb" attack.

billion laughs / exponential entity expansion
   Billion Laughs 攻撃 -- または指数関数的エンティティ展開
   (exponential entity expansion) -- は複数階層の入れ子になったエンテ
   ィティを使用します。 各エンティティは別のエンティティを複数回参照し
   、最終的なエンティティの定義は短い文字列です。 指数関数的に展開され
   ることで数 GB のテキストができ、多くのメモリと CPU 時間を消費します
   。

quadratic blowup entity expansion
   二次爆発攻撃 (quadratic blowup attack) はエンティティ展開を悪用する
   点で Billion Laughs 攻撃に似ています。 入れ子になったエンティティの
   代わりに、この攻撃は数千字の大きなエンティティを何度も繰り返します
   。 この攻撃は指数関数的なものほど効率的ではありませんが、パーザの深
   い入れ子になったエンティティを禁止する対抗手段をすり抜けます。

decompression bomb
   解凍爆弾 (あるいは ZIP 爆弾) は、gzip 圧縮 HTTP ストリームや LZMA
   圧縮ファイルなどの圧縮された XML ストリームをパースできる全ての XML
   ライブラリに対し行われます。 攻撃者は送信データ量を1/3以下に減らす
   ことができます。

large tokens
   Expat needs to re-parse unfinished tokens; without the protection
   introduced in Expat 2.6.0, this can lead to quadratic runtime that
   can be used to cause denial of service in the application parsing
   XML. The issue is known as **CVE 2023-52425**.
