|
|
|
|
|
by SnowflakeOnIce
1491 days ago
|
|
No, you understand. Indeed, by importing Python code, you execute Python code, and so there could be ab execution path for malicious code to run. FYI, pylint does something similar for native-code extension modules (unless this changed in the past few years): it imports them dynamically! EDIT: reading the code more closely and reading the rest of the comments, more precisely, it's not the subprocess call itself, but rather importing an arbitrary Python module, which could be a path for code execution. But this is the case generally with Python: importing a module executes code, and so even just importing (not otherwise executing) an untrusted module could be problematic. |
|
It's a very interesting use case to consider how a similar solution could work as a sandbox for investigating supply chain concerns with third-party libraries that have transitive dependencies. I think some of the static analysis tools referenced in other comments would address this better since the real concern there is detecting the presence of transitive dependencies which may be malicious as opposed to identifying exactly where in the target library those dependencies are used.