@@ -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
298316Backwards Compatibility
299317=======================
@@ -310,6 +328,10 @@ processes that can already write to arbitrary memory within your process and
310328execute arbitrary code on the machine (in order to create the file containing
311329the 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+
313335Existing operating system security mechanisms are effective for guarding
314336against attackers gaining arbitrary memory write access. Although the PEP
315337doesn't specify how memory should be written to the target process, in practice
@@ -368,6 +390,33 @@ proposed interface.
368390By maintaining compatibility with existing security frameworks, this design
369391ensures 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 even if the attacker has compromised the
410+ application **and the filesystem **, leveraging this interface for malicious
411+ purposes provides a very risky proposition for an attacker, as they risk
412+ exposing their actions to system administrators that could not only detect the
413+ attack but also take action to prevent it. Finally, is important to note that
414+ if an attacker has arbitrary memory write access to a process and has compromised
415+ the filesystem, they can already escalate to arbitrary code execution using
416+ other existing mechanisms, so this interface does not introduce any new risks
417+ in this scenario.
418+
419+
371420How to Teach This
372421=================
373422
0 commit comments