you try to install this module
pip install pyseccomp
import pyseccomp
Answer from top talent on Stack Overflowssh - Custom Python Server - how to secure it? - Information Security Stack Exchange
web application - Python's http.server library "basic security checks" - Information Security Stack Exchange
Investigate Python's role in securing IT infrastructure, focusing on server hardening, configuration management, and security automation.
Research Python-based tools and frameworks such as Ansible, Puppet, and Chef, utilized for infrastructure as code (IaC) and automating security tasks.
Discuss how Python empowers organizations to enforce security policies, ensure compliance monitoring, and enhance incident response through streamlined automated processes and workflows.
php - Solving the shared-server security problem for Python - Stack Overflow
Videos
You could turn your python scripts into windows executables using py2exe. That way it would be treated the same way you restrict other system binary. Be aware that it is possible to reverse-engineer by "uncompiling" it, showing the script functions and all. But as your question in only about enforcing execution authorization, i think that it will fulfill your need.
How about the use of PyPy with its sandboxing mode?
I'm afraid I'm not that familiar so I'm uncertain that it would be fully secure but certainly worth a look.
As far as I can see, your only options are:
- PyPy sandboxing
- A Python to executable compiler
- Giving users a Virtual Machine which allows Python
- Using a PC sandboxing solution to isolate Python and the file system.
Python's great, everyone cheers on Python, every weird essential desktop application at the office relies on a Python install, every analyst who has hit the limits of Excel wants to use Python. I don't see anyone really talking about the security implications of having a modular scripting stack with a history of add-on compromise installed on every production workstation.
How do you secure a Python install, what do you allow in it, and how do you cope with the eleventy hundred Python modules users claim they need?