gh-135543: Emit sys.remote_exec audit event when sys.remote_exec is called (GH-135544)

(cherry picked from commit 1ddfe59320)

Co-authored-by: Nadeshiko Manju <me@manjusaka.me>
This commit is contained in:
Miss Islington (bot) 2025-06-19 22:51:06 +02:00 committed by GitHub
parent 83e0ab17f6
commit 0370cb42da
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 79 additions and 20 deletions

View file

@ -1220,7 +1220,7 @@ static inline int run_remote_debugger_source(PyObject *source)
// that would be an easy target for a ROP gadget.
static inline void run_remote_debugger_script(PyObject *path)
{
if (0 != PySys_Audit("remote_debugger_script", "O", path)) {
if (0 != PySys_Audit("cpython.remote_debugger_script", "O", path)) {
PyErr_FormatUnraisable(
"Audit hook failed for remote debugger script %U", path);
return;

View file

@ -2487,6 +2487,11 @@ sys_remote_exec_impl(PyObject *module, int pid, PyObject *script)
if (PyUnicode_FSConverter(script, &path) == 0) {
return NULL;
}
if (PySys_Audit("sys.remote_exec", "iO", pid, script) < 0) {
return NULL;
}
debugger_script_path = PyBytes_AS_STRING(path);
#ifdef MS_WINDOWS
PyObject *unicode_path;