Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Safe Python Environment in Linux

Is it possible to create an environment to safely run arbitrary Python scripts under Linux? Those scripts are supposed to be received from untrusted people and may be too large to check them manually.

A very brute-force solution is to create a virtual machine and restore its initial state after every launch of an untrusted script. (Too expensive.)

I wonder if it's possible to restrict Python from accessing the file system and interacting with other programs and so on.

like image 897
Andrew T Avatar asked Feb 12 '26 03:02

Andrew T


1 Answers

Consider using a chroot jail. Not only is this very secure, well-supported and tested but it also applies to external applications you run from python.

like image 185
SpliFF Avatar answered Feb 14 '26 15:02

SpliFF