Skip to content

Commit c3c3871

Browse files
authored
gh-87604: Clarify in docs that sys.addaudithook is not for sandboxes (GH-99372)
1 parent 3dd6ee2 commit c3c3871

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Doc/library/sys.rst

+9
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ always available.
3535
can then log the event, raise an exception to abort the operation,
3636
or terminate the process entirely.
3737

38+
Note that audit hooks are primarily for collecting information about internal
39+
or otherwise unobservable actions, whether by Python or libraries written in
40+
Python. They are not suitable for implementing a "sandbox". In particular,
41+
malicious code can trivially disable or bypass hooks added using this
42+
function. At a minimum, any security-sensitive hooks must be added using the
43+
C API :c:func:`PySys_AddAuditHook` before initialising the runtime, and any
44+
modules allowing arbitrary memory modification (such as :mod:`ctypes`) should
45+
be completely removed or closely monitored.
46+
3847
.. audit-event:: sys.addaudithook "" sys.addaudithook
3948

4049
Calling :func:`sys.addaudithook` will itself raise an auditing event

0 commit comments

Comments
 (0)