Skip to content

Commit 9f827ea

Browse files
committed
PEP 768: Expand the security considerations section
1 parent 6e1a745 commit 9f827ea

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

peps/pep-0768.rst

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,24 @@ An example usage of the API would look like:
294294
except Exception as e:
295295
print(f"Failed to execute code: {e}")
296296
297+
Configuration API
298+
-----------------
299+
300+
To allow redistributors, system administrators, or users to disable this
301+
mechanism, several methods will be provided to control the behavior of the
302+
interpreter:
303+
304+
A new environment ``PYTHON_DISABLE_REMOTE_DEBUGGING`` environment variable will
305+
be provided to control the behaviour at runtime. If set to any value, the
306+
interpreter will ignore any attempts to attach a debugger using this mechanism.
307+
308+
This environment variable will be added together with a new ``-X disable-remote-debugging``
309+
flag to the Python interpreter to allow users to disable this feature at runtime.
310+
311+
Additionally a new ``--without-remote-debugging`` flag will be added to the
312+
``configure`` script to allow redistributors to build Python without support for
313+
remote debugging if they so desire.
314+
297315

298316
Backwards Compatibility
299317
=======================
@@ -310,6 +328,10 @@ processes that can already write to arbitrary memory within your process and
310328
execute arbitrary code on the machine (in order to create the file containing
311329
the Python code to be executed).
312330

331+
Furtermore, the execution of the code is done is gated by the interpreter's
332+
audit hooks, which can be used to monitor and control the execution of the code
333+
in sensitive environments.
334+
313335
Existing operating system security mechanisms are effective for guarding
314336
against attackers gaining arbitrary memory write access. Although the PEP
315337
doesn't specify how memory should be written to the target process, in practice
@@ -368,6 +390,28 @@ proposed interface.
368390
By maintaining compatibility with existing security frameworks, this design
369391
ensures that adopting the new interface requires no changes to established.
370392

393+
Security scenarios
394+
------------------
395+
396+
* For an external attacker, the ability to write to arbitrary memory in a
397+
process is already a severe security issue. This interface does not introduce
398+
any new attack surface, as the attacker would already have the ability to
399+
execute arbitrary code in the process. This interface behaves in exactly
400+
the same way as existing debuggers, and does not introduce any new additional
401+
security risks.
402+
* For an attacker who has gained arbitrary memory write access to a process but
403+
not arbitrary code execution, this interface does not provide a way to escalate
404+
to arbitrary code execution as long as the attacker has not gained control over
405+
additional machine resources external to the program.
406+
407+
Additionally, the fact that the code to be executed is gated by the interpreter's
408+
audit hooks means that the execution of the code can be monitored and controlled
409+
by system administrators. This means that leveraging this interface for malicious
410+
purposes provides a very risky proposition for an attacker, as they risk exposing
411+
their actions to system administrators that could not only detect the attack but
412+
also take action to prevent it.
413+
414+
371415
How to Teach This
372416
=================
373417

0 commit comments

Comments
 (0)