Skip to content

Commit 7c336ac

Browse files
committed
Doc/library/xml.rst: Improve section on XML security
Clarify that: - it takes parsing for an attack - that some doors are closed by default - only version 2.7.2 has all the fixes - use of the bundle depends on configuration
1 parent 98a41af commit 7c336ac

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

Doc/library/xml.rst

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,21 @@ XML security
5353

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

58-
Expat versions lower than 2.6.0 may be vulnerable to "billion laughs",
59-
"quadratic blowup" and "large tokens". Python may be vulnerable if it uses such
60-
older versions of Expat as a system-provided library.
59+
The builtin XML parsers of Python rely on library `libexpat`_, commonly
60+
called Expat, for parsing XML.
61+
62+
By default, Expat itself does not access local files or create network
63+
connections.
64+
65+
Expat versions lower than 2.7.2 may be vulnerable to "billion laughs",
66+
"quadratic blowup" and "large tokens" or disproportional use of dynamic memory.
67+
Python bundles a copy of Expat, and whether the bundled or a system-wide Expat
68+
is being used by Python, depends on how the Python interpreter
69+
:doc:`has been configured <../using/configure>` in your environment.
70+
Python may be vulnerable if it uses such older versions of Expat.
6171
Check :const:`!pyexpat.EXPAT_VERSION`.
6272

6373
:mod:`xmlrpc` is **vulnerable** to the "decompression bomb" attack.
@@ -90,5 +100,6 @@ large tokens
90100
be used to cause denial of service in the application parsing XML.
91101
The issue is known as :cve:`2023-52425`.
92102

103+
.. _libexpat: https://github.com/libexpat/libexpat
93104
.. _Billion Laughs: https://en.wikipedia.org/wiki/Billion_laughs
94105
.. _ZIP bomb: https://en.wikipedia.org/wiki/Zip_bomb

0 commit comments

Comments
 (0)