Skip to content

Commit c5c5326

Browse files
tonybaloneyambv
andauthored
bpo-39498 Start linking the security warnings in the stdlib modules (GH-18272)
Co-authored-by: Łukasz Langa <[email protected]>
1 parent 058fb35 commit c5c5326

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
@@ -75,3 +75,4 @@ the `Python Package Index <https://pypi.org>`_.
7575
unix.rst
7676
superseded.rst
7777
undoc.rst
78+
security_warnings.rst

Doc/library/logging.config.rst

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

155+
.. _logging-eval-security:
156+
155157
.. note::
156158

157159
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
@@ -54,6 +54,8 @@ lots of shared sub-objects. The keys are ordinary strings.
5454
with shelve.open('spam') as db:
5555
db['eggs'] = 'eggs'
5656

57+
.. _shelve-security:
58+
5759
.. warning::
5860

5961
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
@@ -710,6 +710,7 @@ Exceptions defined in this module all inherit from :exc:`SubprocessError`.
710710
.. versionadded:: 3.3
711711
The :exc:`SubprocessError` base class was added.
712712

713+
.. _subprocess-security:
713714

714715
Security Considerations
715716
-----------------------

Doc/library/tempfile.rst

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

347+
.. _tempfile-mktemp-deprecated:
347348

348349
Deprecated functions and variables
349350
----------------------------------

Doc/library/zipfile.rst

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

889+
.. _zipfile-resources-limitations:
890+
889891
Resources limitations
890892
~~~~~~~~~~~~~~~~~~~~~
891893

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)