Skip to content

Commit fcbe8c6

Browse files
bpo-39498 Start linking the security warnings in the stdlib modules (GH-18272) (GH-27699)
Co-authored-by: Łukasz Langa <[email protected]> (cherry picked from commit c5c5326) Co-authored-by: Anthony Shaw <[email protected]>
1 parent 395f4c7 commit fcbe8c6

File tree

10 files changed

+45
-0
lines changed

10 files changed

+45
-0
lines changed

Doc/library/hashlib.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ library that Python uses on your platform. On most platforms the
8080
.. versionadded:: 3.6
8181
:func:`blake2b` and :func:`blake2s` were added.
8282

83+
.. _hashlib-usedforsecurity:
84+
8385
.. versionchanged:: 3.9
8486
All hashlib constructors take a keyword-only argument *usedforsecurity*
8587
with default value ``True``. A false value allows the use of insecure and

Doc/library/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,4 @@ the `Python Package Index <https://pypi.org>`_.
7676
unix.rst
7777
superseded.rst
7878
undoc.rst
79+
security_warnings.rst

Doc/library/logging.config.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ in :mod:`logging` itself) and defining handlers which are declared either in
147147
send it to the socket as a sequence of bytes preceded by a four-byte length
148148
string packed in binary using ``struct.pack('>L', n)``.
149149

150+
.. _logging-eval-security:
151+
150152
.. note::
151153

152154
Because portions of the configuration are passed through

Doc/library/multiprocessing.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,6 +1187,7 @@ For example:
11871187
>>> arr2
11881188
array('i', [0, 1, 2, 3, 4, 0, 0, 0, 0, 0])
11891189

1190+
.. _multiprocessing-recv-pickle-security:
11901191

11911192
.. warning::
11921193

Doc/library/security_warnings.rst

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
.. _security-warnings:
2+
3+
.. index:: single: security considerations
4+
5+
Security Considerations
6+
=======================
7+
8+
The following modules have specific security considerations:
9+
10+
* :mod:`cgi`: :ref:`CGI security considerations <cgi-security>`
11+
* :mod:`hashlib`: :ref:`all constructors take a "usedforsecurity" keyword-only
12+
argument disabling known insecure and blocked algorithms
13+
<hashlib-usedforsecurity>`
14+
* :mod:`http.server` is not suitable for production use, only implementing
15+
basic security checks
16+
* :mod:`logging`: :ref:`Logging configuration uses eval()
17+
<logging-eval-security>`
18+
* :mod:`multiprocessing`: :ref:`Connection.recv() uses pickle
19+
<multiprocessing-recv-pickle-security>`
20+
* :mod:`pickle`: :ref:`Restricting globals in pickle <pickle-restrict>`
21+
* :mod:`random` shouldn't be used for security purposes, use :mod:`secrets`
22+
instead
23+
* :mod:`shelve`: :ref:`shelve is based on pickle and thus unsuitable for
24+
dealing with untrusted sources <shelve-security>`
25+
* :mod:`ssl`: :ref:`SSL/TLS security considerations <ssl-security>`
26+
* :mod:`subprocess`: :ref:`Subprocess security considerations
27+
<subprocess-security>`
28+
* :mod:`tempfile`: :ref:`mktemp is deprecated due to vulnerability to race
29+
conditions <tempfile-mktemp-deprecated>`
30+
* :mod:`xml`: :ref:`XML vulnerabilities <xml-vulnerabilities>`
31+
* :mod:`zipfile`: :ref:`maliciously prepared .zip files can cause disk volume
32+
exhaustion <zipfile-resources-limitations>`

Doc/library/shelve.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ lots of shared sub-objects. The keys are ordinary strings.
4949
with shelve.open('spam') as db:
5050
db['eggs'] = 'eggs'
5151

52+
.. _shelve-security:
53+
5254
.. warning::
5355

5456
Because the :mod:`shelve` module is backed by :mod:`pickle`, it is insecure

Doc/library/subprocess.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,7 @@ Exceptions defined in this module all inherit from :exc:`SubprocessError`.
683683
.. versionadded:: 3.3
684684
The :exc:`SubprocessError` base class was added.
685685

686+
.. _subprocess-security:
686687

687688
Security Considerations
688689
-----------------------

Doc/library/tempfile.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ Here are some examples of typical usage of the :mod:`tempfile` module::
315315
>>>
316316
# directory and contents have been removed
317317

318+
.. _tempfile-mktemp-deprecated:
318319

319320
Deprecated functions and variables
320321
----------------------------------

Doc/library/zipfile.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,8 @@ Exceeding limitations on different file systems can cause decompression failed.
848848
Such as allowable characters in the directory entries, length of the file name,
849849
length of the pathname, size of a single file, and number of files, etc.
850850

851+
.. _zipfile-resources-limitations:
852+
851853
Resources limitations
852854
~~~~~~~~~~~~~~~~~~~~~
853855

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add a "Security Considerations" index which links to standard library modules that have explicitly documented security considerations.

0 commit comments

Comments
 (0)