From 49b4436c863c9b66ffa21f8eae2d163a1d11f0b0 Mon Sep 17 00:00:00 2001 From: Benoit Favre Date: Fri, 28 Feb 2025 15:07:50 +0100 Subject: [PATCH] jailed exec: prevent imports --- src/public/modules.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/public/modules.c b/src/public/modules.c index 8244e7fa..b32a5fb2 100644 --- a/src/public/modules.c +++ b/src/public/modules.c @@ -69,6 +69,10 @@ int load_module_from_dll_desktop_only(const char* path) PY_RAISE PY_RETURN; int py_import(const char* path_cstr) { VM* vm = pk_current_vm; + if (vm->max_steps > 0) { + ImportError("not allowed in safe context"); + return -1; + } c11_sv path = {path_cstr, strlen(path_cstr)}; if(path.size == 0) return ValueError("empty module name");