]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-87604: Clarify in docs that sys.addaudithook is not for sandboxes (GH-99372)
authorSteve Dower <steve.dower@python.org>
Fri, 11 Nov 2022 13:35:02 +0000 (13:35 +0000)
committerGitHub <noreply@github.com>
Fri, 11 Nov 2022 13:35:02 +0000 (13:35 +0000)
Doc/library/sys.rst

index f3fd16c4de753704025d6cf26bdaaa8298ee4000..d54ecd75a2628f39a6d2eb2da1a48e3f558260e3 100644 (file)
@@ -35,6 +35,15 @@ always available.
    can then log the event, raise an exception to abort the operation,
    or terminate the process entirely.
 
+   Note that audit hooks are primarily for collecting information about internal
+   or otherwise unobservable actions, whether by Python or libraries written in
+   Python. They are not suitable for implementing a "sandbox". In particular,
+   malicious code can trivially disable or bypass hooks added using this
+   function. At a minimum, any security-sensitive hooks must be added using the
+   C API :c:func:`PySys_AddAuditHook` before initialising the runtime, and any
+   modules allowing arbitrary memory modification (such as :mod:`ctypes`) should
+   be completely removed or closely monitored.
+
    .. audit-event:: sys.addaudithook "" sys.addaudithook
 
       Calling :func:`sys.addaudithook` will itself raise an auditing event