2

I am designing a system that will run user submitted python script on a server. The script is meant to have access to only a couple of white-listed modules and nothing else.

One approach to implementing such system securely is to build a custom python interpreter by removing all modules and overriding the underlying mechanism of "import" so that only selected modules can be imported, as explained here. But this approach will require a lot of work on my part.

Another approach is to pre-process the script and check for the presence of keywords "import" and "eval" keywords. If those keywords are present, the script won't be run and alarms will go off. But is there any other way by which one can still import a module and do malicious things?

Jayesh
  • 51,787
  • 22
  • 76
  • 99

0 Answers0