you try to install this module

pip install pyseccomp
import pyseccomp
Answer from top talent on Stack Overflow
🌐
Readthedocs
iri-playbook.readthedocs.io › en › feat-docker › securityhardening.html
Security Hardening — Python documentation
I’d like to repeat this again: ... to your server provided by the hosting provider. It is very important in case something in the configuration goes wrong and you cannot access using SSH anymore. Choose a port number (let’s say 9922) and allow it through the firewall. The following command have to be run as user root or by prefixing the commands with sudo e.g. sudo yum install policycoreutils-python...
🌐
Full Stack Python
fullstackpython.com › web-application-security.html
Web Application Security - Full Stack Python
How to protect your infrastructure against the basic attacker presents a good overview of what you need to think about when hardening your system against reasonablely competent malicious attackers.
Discussions

linux - How can you security-harden a Python program? - Stack Overflow
What is best way to restrict/sandbox a Python program? How can I restrict a Python program to only be able to access one website and print to stdout? I am using pyseccomp to restrict the list of sy... More on stackoverflow.com
🌐 stackoverflow.com
Python security hardening - Information Security Stack Exchange
I’m working for a large organization which is using some Windows products that require python to work. Python is used to execute built in utility scripts and the user never recognizes that python... More on security.stackexchange.com
🌐 security.stackexchange.com
ssh - Custom Python Server - how to secure it? - Information Security Stack Exchange
I'm going to purchase my own dedicated server service soon and run few python server scripts on it. Firstly, let me tell you that I am total noob when it comes to internet security and was unable to More on security.stackexchange.com
🌐 security.stackexchange.com
Basic Server Hardening Steps
An excellent source of security benchmark and best practices https://www.cisecurity.org/benchmark/ubuntu_linux/ More on reddit.com
🌐 r/selfhosted
110
301
June 5, 2021
🌐
SecureCoding
securecoding.com › home › blog › how to automate server hardening
How to Automate Server Hardening - SecureCoding
June 15, 2022 - GrapheneX is an open-source Python-based framework that automatically secures the severs with a different checklist of hardening commands. A significant difference between GrapheneX and other tools is that it’s designed to be used by Linux and Windows developers because of its interface options. Server ...
🌐
GitHub
github.com › insidious-security › server-hardening
GitHub - insidious-security/server-hardening: Linux server hardening
# Git clone this repository: $ git clone https://github.com/insidious-security/server-hardening.git # Install python dependency: $ pip3 install requests # Run the code: python3 harden.py
Author   insidious-security
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-system-hardening-and-compliance-reports-using-lynis
Python | System hardening and compliance reports using Lynis - GeeksforGeeks
November 8, 2021 - #!/bin/bash # script to scrape/parse the report file and # extract the relevant details and run the # python script to display the details in a server. echo "running......" echo "" sudo ./lynis audit system --quick # execute warnings.
Find elsewhere
🌐
Medium
verlekarsachin.medium.com › automate-your-cis-server-hardening-baseline-documentation-using-python-e59da5ff0a78
Automate Your CIS Server Hardening Baseline Documentation using Python | by Sachin Verlekar | Medium
January 7, 2024 - As security professionals, we know the importance of server hardening and following industry best practices like CIS benchmarks. But let’s be honest, manually extracting every recommendation from those hefty documents can be tedious and time-consuming. It eats into valuable hours that could be spent on analysis, remediation, and other critical tasks. Enter the power of automation! I’m excited to share with you my custom Python script I’ve developed that streamlines the CIS baseline documentation process, saving you up to a whopping 70% of your time.
🌐
Medium
medium.com › @obaff › 10-python-scripts-to-automate-security-hardening-in-devops-dd6434cf374f
10 Python Scripts to Automate Security Hardening in DevOps | by Obafemi | Medium
April 8, 2025 - 10 Python Scripts to Automate Security Hardening in DevOps automate various security hardening tasks 1. Password Strength Checker This script validates passwords against common rules (length …
🌐
GitHub
github.com › topics › security-hardening
security-hardening · GitHub Topics · GitHub
application application-security web-security security-vulnerability security-hardening appsec vulnerability-scanners security-scanner security-tools web-security-research security-testing endpoint-security mobilesecurity mdm-server developer-security security-advisory ... UDP port knocking suite with HMAC-PSK authentication. security networking network security-hardening stealth post-quantum-cryptography port-knocker firewall-management post-quantum port-knock ... Want to see how something like Internet Chemotherapy works without bricking your own vms? This is a jail to reduce the python runtime from doing bad things on the host when running untrusted code.
🌐
GitHub
github.com › topics › hardening
hardening · GitHub Topics · GitHub
python cis tool audit python3 python-3 hardening score cis-benchmark python38 cis-hardening python3-8 cis-benchmarks cis-center-for-internet-security cis-linux-benchmark cis-debian-benchmark cis-ubuntu-benchmark ... BAT is a tool to help everyone to securing their web-servers.
🌐
Reddit
reddit.com › r/selfhosted › basic server hardening steps
r/selfhosted on Reddit: Basic Server Hardening Steps
June 5, 2021 -

I recently leased a VPS to host a few services, and took the first steps towards locking down the server (Ubuntu Server 20.04).

What I have done so far:

  • Update & Upgrade the system

  • Install / enable unattended-upgrades & apt-listchanges (automatically install important updates daily, and monitor/list changes automatically)

  • Create a non-root user, add to sudoers

  • Lock down SSH

    • Change to a nonstandard port

    • Create & configure key based SSH login (key protected with password)

    • Disable root login via SSH

    • Disable password login via SSH

  • Configure Firewall

    • Create rule to allow but limit SSH in on new port

    • Create rules to allow in, on other necessary ports (for me just 80 and 443)

    • Set default deny for everything else.

    • Rule to drop ping requests

    • Enable firewall

  • Setup fail2ban for SSH

    • Rather relaxed 15/15/15 rule (15 failed logins, in 15 minutes = 15 minute ban)

  • Check to make sure apparmor is enabled and in enforcement mode

On the to-do / research list are (1) setting up mail so important system mail is sent (or forwarded from 'root') to my actual e-mail address (2) figuring out backups of some sort

What additional steps would you take?

What have I left out / forgotten / got wrong?

🌐
GitHub
github.com › decalage2 › awesome-security-hardening
GitHub - decalage2/awesome-security-hardening: A collection of awesome security hardening guides, tools and other resources · GitHub
CryptoLyzer - Fast, flexible and comprehensive server cryptographic protocol (TLS, SSL, SSH, DNSSEC) and related setting (HTTP headers, DNS records) analyzer and fingerprint (JA3, HASSH tag) generator with Python API and CLI.
Starred by 6.3K users
Forked by 646 users
🌐
GitHub
github.com › ossf › wg-best-practices-os-developers › issues › 481
[New SIG] Create Python Hardening Guide · Issue #481 · ossf/wg-best-practices-os-developers
May 6, 2024 - Our friends at Ericsson have developed a set of code examples and guidance grounded in the MITRE CWE framework (https://cwe.mitre.org/). This work was originally inspired by SEI Cert's secure coding material, with the intention of translating those to Python to educate new and experienced developers and enable future automation with valid code examples.
Author   SecurityCRob
🌐
Cyfuture Cloud
cyfuture.cloud › kb › howto › how-to-secure-a-python-server-best-practices--tls-setup
How to Secure a Python Server: Best Practices & TLS Setup
Configure Nginx to Proxy to Gunicorn or uWSGI server { ... Force HTTPS Add a redirect block in your Nginx config to force all HTTP traffic to HTTPS. For testing or internal apps, you can serve HTTPS directly using Python’s built-in ssl module: ... Again, don’t use this in production—it lacks performance optimizations and hardening ...
Top answer
1 of 1
8

The problem isn't that there are known security vulnerabilities.

The problem is that there is not really an effort to address less common but critical vulnerabilities.

For example, many web servers will display error messages. Until quite recently, Apache Httpd would include some of the request data in the error pages, which allowed cross-site scripting in default configurations of mod_proxy (CVE-2019-10092), with no way for the application developers to mitigate this threat against the site users.

The major web servers, such as Apache Httpd, Nginx, IIS, and Lighttpd each have hundreds of active contributors (or in IIS's case, a large corporate structure behind it), dozens of core developers who understand security best practices, and a team dedicated specifically to reviewing code for potential vulnerabilities. As you can tell by browsing the CVEs of any of those projects, there are still things that people catch after versions are released.

The developers who write HTTP servers for programming languages are small sub-projects, developing tools to support the main product: The language. There might be a dozen people who have contributed code to that tool, and one or two core developers on that project.

They do not have the resources available to search for vulnerabilities, so while there aren't any known vulnerabilities (or at the very least, it is very bad form here to point out known vulnerabilities that are likely to remain unaddressed), there are most certainly vulnerabilities in it, simply due to the complex nature of HTTP servers.

Some of these vulnerabilities might be extremely critical, such as allowing an attacker to have complete control over your server, including executing arbitrary code with a privileged account. Such a vulnerability might not exist, but without a thorough code review—and with the large, red-boxed warning at the top of Python's documentation page—it is plausible that such a vulnerability might exist.

In your specific case, the CIO signed off on it.

It is the CIO's responsibility to ensure that risk assessments are done. As the sysadmin, it's your job to execute the company's officers' instructions, and your responsibility to ensure that the officers have the information they need to be able to make informed decisions.

Because of the boundary in responsibilities, the pushback that I would do is ask to see the risk assessment. If the risk assessment doesn't include a very high probability (due to automated tools quickly finding the vulnerable server in hours) that the server gets infected with malware and used as a Command and Control repeater node for a bot farm, offer to help them make a realistic risk assessment.

🌐
GitHub
github.com › topics › server-hardening
server-hardening · GitHub Topics · GitHub
Linux server hardening · python linux hardening linux-hardening server-hardening · Updated · Feb 12, 2023 · Python · Star 1 · Comprehensive POSIX shell server hardening toolkit with automatic rollback, SSH safety, and Ansible automation for Debian-based systems ·
🌐
DEV Community
dev.to › cwprogram › python-networking-servers-4jm1
Python Networking: Servers - DEV Community
July 23, 2023 - I generally prefer doing it at ... network hardening in easy to update software than trying to handle it across who knows how many codebases. So basically: ... So we'll start with an echo server that simply replies back to the client with what it was sent. Here is some example code from the python ...