Skip to main content

PYPI: https://pypi.org/project/supply-chain-guard/

PyPI version Python Versions License: MIT Downloads

🛡 Features

  • Import Interception: Blocks unauthorized access to sensitive environment variables (e.g., AWS_SECRET_ACCESS_KEY, DATABASE_URL) during package initialization.
  • File System Guard: Prevents third-party packages from reading sensitive files like ~/.ssh/id_rsa or ~/.aws/credentials.
  • OS-level Telemetry & Execution Prevention: Uses Python's native Audit Hooks (PEP 578) to actively block remote code execution (os.system, subprocess) and reverse shell network connections (socket.connect) at the moment a suspicious package is imported.

🚀 Installation

Install the package via pip:

pip install supply-chain-guard

🛡️ Usage

⚙️ Enterprise Configuration (.guardrc)

By default, protection works out of the box. To block custom proprietary secrets, place .guardrc in your project root:

{
  "version": "1.0",
  "blocked_env_vars": [
    "INTERNAL_CORP_TOKEN",
    "CUSTOM_DB_PASS"
  ],
  "blocked_paths": [
    "/etc/internal_certs"
  ]
}

Or set a custom path via environment variable:

export GUARD_CONFIG_PATH="/path/to/company_policy.json"

Option 1: Direct Import

Import the guard at the very first line of your entry point script (main.py, app.py, etc.) to protect your application:

import supply_chain_guard  # Protection starts here
import requests
# ... your other imports

Option 2: Protect Environment

  1. Run in your environment 'setup_protection.sh' it will make your repository protected as long as you use this (virtual) environment
chmod +x ./setup_protection.sh
  1. Execute setup_protection.sh
./setup_protection.sh

Option 3: Protecting Jupyter Notebook Servers

If you manage a Jupyter server for students or a team, you can enforce security globally. This ensures that every notebook is protected, even if users try to install malicious packages themselves.

Steps for Administrator:

  1. Install the package in the Python environment used by your Jupyter server:

    pip install supply-chain-guard
    
  2. Get the startup directory for IPython Notebook

    python -c "from IPython import get_ipython; print(get_ipython().profile_dir.startup_dir)"
    
  3. Create '0_force_imports.py'

     # ~/.ipython/profile_default/startup/force_imports.py
     try:
         import supply_chain_guard
         print("✅ Supply Chain Guard installed")
     except ImportError as e:
         print(f"⚠️  Import Not implemented: {e}") 
    
  4. Restart IPyhton Notebook Server and it will force 'supply_chain_guard' to all kernels of Jupyter

< Installation by hand >

Show

python3 -m venv venv

source venv/bin/activate

pip install -e .

Test packages isntallation

pip install -e test_package/clean_pkg

pip install -e test_package/malware_pkg

pip install -e test_package/sheep_package #which has dependency from 'malicious' wolf_package

Architecture & Detection Pipeline

View Schema Image

Architecture

View Mermaid Source
graph TD
    A[Python Package Execution / Import] --> B[sys.addaudithook Runtime Interceptor]
    B --> C{Behavioral Engine}
    C -->|Telemetry: Network / Syscalls| D[OS-Level Telemetry Monitor]
    C -->|Policy Check: Blacklisted Tokens| E[Enterprise Rule Engine (.guardrc)]
    D --> F{Threat Detected?}
    E --> F
    F -->|Yes| G[Runtime Execution Terminated + Alert Raised]
    F -->|No| H[Safe Package Execution]

Overview & Strategic Importance

Supply-Chain-Guard is an automated, container-ready dynamic analysis framework designed to detect and intercept malicious code execution in Python third-party dependencies during runtime and installation.

Targeting critical software supply chain vulnerabilities (such as typosquatting, dependency confusion, and hidden payloads), this project aligns with U.S. Executive Order 14028 (Improving the Nation's Cybersecurity) and adheres to the NIST SP 800-218 Secure Software Development Framework (SSDF).

Metadata

Release files for supply-chain-guard 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for supply-chain-guard 0.4.1
File Size Uploaded Provenance Actions
supply_chain_guard-0.4.1.tar.gz 6.5 kB Without provenance Details for supply_chain_guard-0.4.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for supply-chain-guard 0.4.1
File Interpreter ABI Platform Actions
supply_chain_guard-0.4.1-py3-none-any.whl Python 3 none any Details for supply_chain_guard-0.4.1-py3-none-any.whl

Total release size: 13.4 kB

Release files / supply_chain_guard-0.4.1.tar.gz

Download URL supply_chain_guard-0.4.1.tar.gz
Size 6.5 kB
Tags Source
SHA-256 checksum
How to use checksums
9c269ce737eaddaa01ec1f075a37aa32b82ec0c3e76d32178df69ce604cda870
BLAKE2b-256 checksum
How to use checksums
d2125dcbf41fabac4507f13c093cb3b336d7d0a038c5cb595ac79760805a15b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release files / supply_chain_guard-0.4.1-py3-none-any.whl

Download URL supply_chain_guard-0.4.1-py3-none-any.whl
Size 6.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bb4c29a42765bdcdfaecf8785286341f2f0b47f0bd3325c3b00cffb8fdf4783b
BLAKE2b-256 checksum
How to use checksums
182c43137000396e09b060520e6b1f8a09e153a89216344e83503790958e2ec6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Security for supply-chain-guard 0.4.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page