Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

This checklist is designed to help prevent security issues before running an unknown or third-party Python program.

This checklist covers key security principles for safely running Python programs.

So this means if you want to avoid security risks when using Python programs:

Must do actions

1. Install Python programs only from trusted sources.

Use only official, managed repositories such as:
-    PyPI.org
-    conda
-    conda-forge
Never download or execute Python programs from untrusted websites, random forums, or unknown Git repositories. This helps reduce the risk of supply chain attacks that could compromise your system.

Only run Python scripts if you fully understand what they do and where they came from.

2. Perform a basic security (SAST) check.

Avoid running Python scripts that show warnings or ask an expert to explain the warnings for you.

3. Always use a virtual environment:

4. Be Careful with dependencies

pip install <package>

or:

conda install <package>

Avoid software that requires manual installation of system libraries or packages outside these tools — unless done in an isolated environment such as a virtual machine, container, or BSD jail.

5. Use isolation for higher risk programs

For robust security, do not rely on Python itself for sandboxing. So encapsulate the runtime CPython environment in a dedicated, externally managed sandbox. This design ensures that the Python environment remains isolated, significantly reducing the risk of exploitation.

If your SAST scan raises any concerns, run the program in an isolated environment, such as:

The isolated environment should:

So always implement privilege separation outside Python by running it within a sandboxed environment. This reduces risks by isolating the Python process from critical system resources.

6. Use Open Source(FOSS) programs

This allows the code to be inspected and audited for security issues when needed.

FOSS software is not automatic more secure that commercial software. But having the source code is available means it is easier to evaluate security aspects. Transparency is a key pillar in building trust and validating security claims.

7. Check for security validation from the author or maintainers:

- Verify if the program has been scanned for security weaknesses by its creator.
- Look for a “Python Code Audit Badge”:

- or similar trusted security validation indicator.

If you cannot find such a badge, ask the creator:
-    What SAST tool was used?
-    Can they share a scan report for the released version?

8. Keep Python and packages updated

pip list –outdated

or

pip install –upgrade <package>
  1. Have a recovery plan

If something suspicious happens when running a Python program, disconnect from the internet immediately.

Could do actions

When you want more certainty and control to prevent security risks, consider taking the following additional measures.

1. Avoid programs with dependencies on closed-source external APIs or cloud platforms.

Such connections may expose sensitive data or create dependencies on systems outside your control.

2. Avoid programs that use telemetry or tracking

These features often share information about your system or activity without full transparency. Even when intended for diagnostics, telemetry can reduce privacy and increase security risks if data is intercepted or misused.

3. Review and validate dependencies for security weaknesses

4. Verify that the software is actively maintained

5. Check for a responsible security policy

checklist_python_use