Skip to content

Commit

Permalink
gh-87604: Clarify in docs that sys.addaudithook is not for sandboxes (G…
Browse files Browse the repository at this point in the history
  • Loading branch information
zooba authored Nov 11, 2022
1 parent 3dd6ee2 commit c3c3871
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Doc/library/sys.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c3c3871

Please sign in to comment.