Skip to content

gh-159398: Validate strings read from remote process in _remote_debugging - #159402

Open
StanFromIreland wants to merge 5 commits into
python:mainfrom
StanFromIreland:gh-159398
Open

StanFromIreland wants to merge 5 commits into
python:mainfrom
StanFromIreland:gh-159398

Conversation

@StanFromIreland

@StanFromIreland StanFromIreland commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

Instead of copying the remote bytes straight into a str, we now read them into a temp buffer and build the result with PyUnicode_FromKindAndData, which validates the characters and picks the narrowest kind. Bad names raise an error so we end up with <unknown function>.

Comment thread Modules/_remote_debugging/object_reading.c
Comment thread Modules/_testinternalcapi.c Outdated
Co-authored-by: vstinner@python.org
@maurycy

maurycy commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

I reran the Tools/inspection/oracle_external_inspection.py on macOS, no change.

Comment thread Lib/test/test_external_inspection.py
Comment thread Lib/test/test_external_inspection.py
Comment thread Modules/_remote_debugging/object_reading.c Outdated
@vstinner vstinner added the needs backport to 3.15 bugs and security fixes label Oct 15, 2026
@vstinner

Copy link
Copy Markdown
Member

In Python 3.14, read_py_str() of Modules/_remote_debugging_module.c calls PyUnicode_FromStringAndSize(). I don't get how it works. It reads the UTF-8 representation of a string? What if the Unicode object has no UTF-8 representation? So it's unclear to me if Python 3.14 is also affected by the issue.

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Just some minor suggestions.

Comment thread Modules/_testinternalcapi.c Outdated
Comment thread Lib/test/test_external_inspection.py Outdated
StanFromIreland and others added 3 commits October 16, 2026 16:04
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-Authored-By: Maurycy Pawłowski-Wieroński <maurycy@maurycy.com>

@maurycy maurycy left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants