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

This commit is contained in:
Nadeshiko Manju 2025-06-20 04:23:38 +08:00 committed by GitHub
parent bb9596fcfa
commit 1ddfe59320
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

@ -2488,6 +2488,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;