Skip to content

Commit e2b1b00

Browse files
Deploy preview for PR 1214 🛫
1 parent 5f1c774 commit e2b1b00

File tree

586 files changed

+749
-610
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

586 files changed

+749
-610
lines changed

pr-preview/pr-1214/_sources/howto/remote_debugging.rst.txt

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,3 +624,58 @@ To inject and execute a Python script in a remote process:
624624
6. Set ``_PY_EVAL_PLEASE_STOP_BIT`` in the ``eval_breaker`` field.
625625
7. Resume the process (if suspended). The script will execute at the next safe
626626
evaluation point.
627+
628+
.. _remote-debugging-threat-model:
629+
630+
Security and threat model
631+
=========================
632+
633+
The remote debugging protocol relies on the same operating system primitives
634+
used by native debuggers such as GDB and LLDB. Attaching to a process
635+
requires the **same privileges** that those debuggers require, for example
636+
``ptrace`` / Yama LSM on Linux, ``task_for_pid`` on macOS, and
637+
``SeDebugPrivilege`` on Windows. Python does not introduce any new privilege
638+
escalation path; if an attacker already possesses the permissions needed to
639+
attach to a process, they could equally use GDB to read memory or inject
640+
code.
641+
642+
The following principles define what is, and is not, considered a security
643+
vulnerability in this feature:
644+
645+
Attaching requires OS-level privileges
646+
On every supported platform the operating system gates cross-process
647+
memory access behind privilege checks (``CAP_SYS_PTRACE``, root, or
648+
administrator rights). A report that demonstrates an issue only after
649+
these privileges have already been obtained is **not** a vulnerability in
650+
CPython, since the OS security boundary was already crossed.
651+
652+
Crashes or memory errors when reading a compromised process are not vulnerabilities
653+
A tool that reads internal interpreter state from a target process must
654+
trust that memory to be well-formed. If the target process has been
655+
corrupted or is controlled by an attacker, the debugger or profiler may
656+
crash, produce garbage output, or behave unpredictably. This is the same
657+
risk accepted by every ``ptrace``-based debugger. Bugs in this category
658+
(buffer overflows, segmentation faults, or undefined behaviour triggered
659+
by reading corrupted state) are **not** treated as security issues, though
660+
fixes that improve robustness are welcome.
661+
662+
Vulnerabilities in the target process are not in scope
663+
If the Python process being debugged has already been compromised, the
664+
attacker already controls execution in that process. Demonstrating further
665+
impact from that starting point does not constitute a vulnerability in the
666+
remote debugging protocol.
667+
668+
When to use ``PYTHON_DISABLE_REMOTE_DEBUG``
669+
-------------------------------------------
670+
671+
The environment variable :envvar:`PYTHON_DISABLE_REMOTE_DEBUG` (and the
672+
equivalent :option:`-X disable_remote_debug` flag) allows operators to disable
673+
the in-process side of the protocol as a **defence-in-depth** measure. This
674+
may be useful in hardened or sandboxed deployment environments where no
675+
debugging or profiling of the process is expected and reducing attack surface
676+
is a priority, even though the OS-level privilege checks already prevent
677+
unprivileged access.
678+
679+
Setting this variable does **not** affect other OS-level debugging interfaces
680+
(``ptrace``, ``/proc``, ``task_for_pid``, etc.), which remain available
681+
according to their own permission models.

pr-preview/pr-1214/_sources/library/argparse.rst.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1111,7 +1111,15 @@ User defined functions can be used as well:
11111111

11121112
The :func:`bool` function is not recommended as a type converter. All it does
11131113
is convert empty strings to ``False`` and non-empty strings to ``True``.
1114-
This is usually not what is desired.
1114+
This is usually not what is desired::
1115+
1116+
>>> parser = argparse.ArgumentParser()
1117+
>>> _ = parser.add_argument('--verbose', type=bool)
1118+
>>> parser.parse_args(['--verbose', 'False'])
1119+
Namespace(verbose=True)
1120+
1121+
See :class:`BooleanOptionalAction` or ``action='store_true'`` for common
1122+
alternatives.
11151123

11161124
In general, the ``type`` keyword is a convenience that should only be used for
11171125
simple conversions that can only raise one of the three supported exceptions.

pr-preview/pr-1214/_sources/using/configure.rst.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -838,9 +838,11 @@ See also the :ref:`Python Development Mode <devmode>` and the
838838
:option:`--with-trace-refs` configure option.
839839

840840
.. versionchanged:: 3.8
841-
Release builds and debug builds are now ABI compatible: defining the
841+
Release builds are now ABI compatible with debug builds: defining the
842842
``Py_DEBUG`` macro no longer implies the ``Py_TRACE_REFS`` macro (see the
843-
:option:`--with-trace-refs` option).
843+
:option:`--with-trace-refs` option). However, debug builds still expose
844+
more symbols than release builds and code built against a debug build is not
845+
necessarily compatible with a release build.
844846

845847

846848
Debug options

pr-preview/pr-1214/_sources/whatsnew/3.8.rst.txt

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -207,14 +207,15 @@ subdirectories).
207207
Debug build uses the same ABI as release build
208208
-----------------------------------------------
209209

210-
Python now uses the same ABI whether it's built in release or debug mode. On
211-
Unix, when Python is built in debug mode, it is now possible to load C
212-
extensions built in release mode and C extensions built using the stable ABI.
213-
214-
Release builds and :ref:`debug builds <debug-build>` are now ABI compatible: defining the
215-
``Py_DEBUG`` macro no longer implies the ``Py_TRACE_REFS`` macro, which
216-
introduces the only ABI incompatibility. The ``Py_TRACE_REFS`` macro, which
217-
adds the :func:`sys.getobjects` function and the :envvar:`PYTHONDUMPREFS`
210+
The ABI of Python :ref:`debug builds <debug-build>` is now compatible with
211+
Python release builds. On Unix, when Python is built in debug mode, it is now
212+
possible to load C extensions built in release mode and C extensions built
213+
using the stable ABI. The inverse is not true, as debug builds expose
214+
additional symbols not available in release builds.
215+
216+
Defining the ``Py_DEBUG`` macro no longer implies the ``Py_TRACE_REFS`` macro,
217+
which introduces the only ABI incompatibility. The ``Py_TRACE_REFS`` macro,
218+
which adds the :func:`sys.getobjects` function and the :envvar:`PYTHONDUMPREFS`
218219
environment variable, can be set using the new :option:`./configure
219220
--with-trace-refs <--with-trace-refs>` build option.
220221
(Contributed by Victor Stinner in :issue:`36465`.)

pr-preview/pr-1214/about.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ <h3>導航</h3>
356356
<a href="https://www.python.org/psf/donations/">敬請捐贈。</a>
357357
<br>
358358
<br>
359-
最後更新於 4月 03, 2026 (00:29 UTC)。
359+
最後更新於 4月 04, 2026 (00:27 UTC)。
360360

361361
<a href="/bugs.html">發現 bug</a>
362362

pr-preview/pr-1214/bugs.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ <h2>說明文件的錯誤<a class="headerlink" href="#documentation-bugs" title=
250250
</section>
251251
<section id="getting-started-contributing-to-python-yourself">
252252
<span id="contributing-to-python"></span><h2>開始讓自己貢獻 Python<a class="headerlink" href="#getting-started-contributing-to-python-yourself" title="連結到這個標頭"></a></h2>
253-
<p>除了只是回報你所發現的錯誤之外,同樣也歡迎你提交修正它們的修補程式 (patch)。你可以在 <a class="reference external" href="https://mail.python.org/mailman3/lists/core-mentorship.python.org/">Python 開發者指南</a>中找到如何開始修補 Python 的更多資訊。如果你有任何問題,<a class="reference external" href="https://devguide.python.org/">核心導師郵寄清單</a>是一個友善的地方,你可以在那裡得到,關於 Python 修正錯誤的過程中,所有問題的答案。</p>
253+
<p>除了只是回報你所發現的錯誤之外,同樣也歡迎你提交修正它們的修補程式 (patch)。你可以在 <a class="reference external" href="https://devguide.python.org/">Python 開發者指南</a>中找到如何開始修補 Python 的更多資訊。如果你有任何問題,<a class="reference external" href="https://mail.python.org/mailman3/lists/core-mentorship.python.org/">核心導師郵寄清單</a>是一個友善的地方,你可以在那裡得到,關於 Python 修正錯誤的過程中,所有問題的答案。</p>
254254
</section>
255255
</section>
256256

@@ -393,7 +393,7 @@ <h3>導航</h3>
393393
<a href="https://www.python.org/psf/donations/">敬請捐贈。</a>
394394
<br>
395395
<br>
396-
最後更新於 4月 03, 2026 (00:29 UTC)。
396+
最後更新於 4月 04, 2026 (00:27 UTC)。
397397

398398
<a href="/bugs.html">發現 bug</a>
399399

pr-preview/pr-1214/c-api/abstract.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ <h3>導航</h3>
365365
<a href="https://www.python.org/psf/donations/">敬請捐贈。</a>
366366
<br>
367367
<br>
368-
最後更新於 4月 03, 2026 (00:29 UTC)。
368+
最後更新於 4月 04, 2026 (00:27 UTC)。
369369

370370
<a href="/bugs.html">發現 bug</a>
371371

pr-preview/pr-1214/c-api/allocation.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ <h3>導航</h3>
574574
<a href="https://www.python.org/psf/donations/">敬請捐贈。</a>
575575
<br>
576576
<br>
577-
最後更新於 4月 03, 2026 (00:29 UTC)。
577+
最後更新於 4月 04, 2026 (00:27 UTC)。
578578

579579
<a href="/bugs.html">發現 bug</a>
580580

pr-preview/pr-1214/c-api/apiabiversion.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ <h3>導航</h3>
514514
<a href="https://www.python.org/psf/donations/">敬請捐贈。</a>
515515
<br>
516516
<br>
517-
最後更新於 4月 03, 2026 (00:29 UTC)。
517+
最後更新於 4月 04, 2026 (00:27 UTC)。
518518

519519
<a href="/bugs.html">發現 bug</a>
520520

pr-preview/pr-1214/c-api/arg.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -996,7 +996,7 @@ <h3>導航</h3>
996996
<a href="https://www.python.org/psf/donations/">敬請捐贈。</a>
997997
<br>
998998
<br>
999-
最後更新於 4月 03, 2026 (00:29 UTC)。
999+
最後更新於 4月 04, 2026 (00:27 UTC)。
10001000

10011001
<a href="/bugs.html">發現 bug</a>
10021002

0 commit comments

Comments
 (0)