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.3.2

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.3.2
File Size Uploaded Provenance Actions
supply_chain_guard-0.3.2.tar.gz 6.5 kB Without provenance Details for supply_chain_guard-0.3.2.tar.gz

Built distribution (wheel)

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

Total release size: 13.4 kB

Release files / supply_chain_guard-0.3.2.tar.gz

Download URL supply_chain_guard-0.3.2.tar.gz
Size 6.5 kB
Tags Source
SHA-256 checksum
How to use checksums
907f99498f1a975d96fc19be8676099043801157c4a1216bc1d4e6f3f64de731
BLAKE2b-256 checksum
How to use checksums
47dbe06cfdc9fb0090b16706aff5ef7729ac876be815df745b0543f6c42c569f
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.3.2-py3-none-any.whl

Download URL supply_chain_guard-0.3.2-py3-none-any.whl
Size 6.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
773319df7262d1ed26aac31a58bcb8251a80aeb85e0b8964357a7e1173e4f74e
BLAKE2b-256 checksum
How to use checksums
3aeabb6e05604e868264afc09319579c14c90581f34cc281a1ea32c31b91cb77
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.3.2

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