you try to install this module
pip install pyseccomp
import pyseccomp
Answer from top talent on Stack OverflowPython security hardening - Information Security Stack Exchange
ssh - 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.
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.
I am looking for a script that will automate the hardening of a Linux server (looking at Ubuntu distro right now). I happened upon this: https://github.com/Jsitech/JShielder/blob/master/UbuntuServer_18.04LTS/jshielder.sh which looks VERY comprehensive. My only thing with this is that it may be overkill, and possibly even some redundancy exists. Was wondering what everyone uses?
Ansible.
It looks like that script is trying to do configuration management. So why not use a configuration management tool to do so? (ansible, puppet, cfengine, etc.)
You should separate the "what configurations need to be made to secure/harden a system" and "what tool will I use to implement it".
I'm working with RHEL but I use Ansible playbooks to audit and apply DISA STIG settings.
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?