A comprehensive cybersecurity learning platform for understanding, practicing, and defending against supply chain attacks.
This test bench provides hands-on practical scenarios to learn about supply chain attacks - one of the most critical and emerging threats in modern software development. Candidates will set up vulnerable environments, execute attacks, detect compromises, and implement defenses.
- Typosquatting Attacks: How attackers exploit package name confusion
- Dependency Confusion: Private vs public package resolution vulnerabilities
- Compromised Packages: How legitimate packages get hijacked
- Malicious Updates: Trojan horse updates to trusted packages
- Build System Compromise: CI/CD pipeline exploitation
- Shai-Hulud Attack: Self-replicating supply chain attacks with credential harvesting
- Transitive Dependency Attacks: Attacks through dependencies of dependencies
- Package Lock File Manipulation: Attacks through manipulated lock files
- Package Signing Bypass: Attacks through compromised signing keys
- Git Submodule Attacks: Attacks through malicious git submodules
- Registry Mirror Poisoning: Attacks through compromised internal mirrors (Enterprise-specific)
- Workspace/Monorepo Attack: Attacks through compromised workspace packages (Common in modern development)
- Detection & Mitigation: Tools and techniques to defend your supply chain
- Operating System: Linux, macOS, or Windows with WSL2
- Software Requirements:
- Python 3.8+
- Node.js 16+
- Git
- Docker & Docker Compose (optional, for advanced scenarios)
- Knowledge Level: Basic understanding of package managers (npm, pip, etc.)
testbench/
βββ scenarios/ # Attack scenario labs
β βββ 01-typosquatting/ # Lab 1: Typosquatting attack
β βββ 02-dependency-confusion/ # Lab 2: Dependency confusion
β βββ 03-compromised-package/ # Lab 3: Package compromise
β βββ 04-malicious-update/ # Lab 4: Update attacks
β βββ 05-build-compromise/ # Lab 5: CI/CD compromise
β βββ 06-sha-hulud/ # Lab 6: Self-replicating attack
β βββ 07-transitive-dependency/ # Lab 7: Transitive dependency attack
β βββ 08-package-lock-file-manipulation/ # Lab 8: Lock file manipulation
β βββ 09-package-signing-bypass/ # Lab 9: Package signing bypass
β βββ 10-git-submodule-attack/ # Lab 10: Git submodule attack
β βββ 11-registry-mirror-poisoning/ # Lab 11: Registry mirror poisoning
β βββ 12-workspace-monorepo-attack/ # Lab 12: Workspace/monorepo attack
βββ vulnerable-apps/ # Sample vulnerable applications
β βββ nodejs-app/ # Vulnerable Node.js application
β βββ python-app/ # Vulnerable Python application
β βββ build-pipeline/ # Vulnerable CI/CD setup
βββ malicious-packages/ # Example malicious packages (for learning)
βββ detection-tools/ # Security scanning and detection tools
βββ docker/ # Docker configurations
βββ docs/ # Detailed documentation
βββ scripts/ # Setup and utility scripts
If you're completely new and want step-by-step guidance:
-
Run the interactive starter script:
chmod +x START_HERE.sh ./START_HERE.sh
-
Or read the complete beginner's guide:
cat docs/ZERO_TO_HERO.md
This guide will take you from zero knowledge to completing your first scenario with detailed explanations of every step.
git clone <repository-url>
cd testbenchchmod +x scripts/setup.sh
./scripts/setup.shcd scenarios/01-typosquatting
cat README.md # Read the scenario instructionsDuration: 30-45 minutes
Objective: Create and exploit a typosquatted package to exfiltrate data
Skills: Package creation, social engineering, data exfiltration
Duration: 45-60 minutes
Objective: Exploit private/public package resolution to inject malicious code
Skills: Package registry manipulation, scope confusion
Duration: 60 minutes
Objective: Simulate account takeover and malicious package update
Skills: Credential compromise, package hijacking
Duration: 60-90 minutes
Objective: Deploy a trojan update that appears legitimate
Skills: Code obfuscation, persistence techniques
Duration: 90+ minutes
Objective: Compromise CI/CD pipeline to inject backdoors
Skills: Pipeline manipulation, artifact poisoning
Duration: 120+ minutes
Objective: Understand and defend against self-replicating supply chain attacks
Skills: Credential harvesting, post-install exploitation, forensic analysis, incident response
Description: Learn about one of the most sophisticated supply chain attacks that compromised hundreds of npm packages. This scenario covers credential theft, self-replication mechanisms, and comprehensive incident response.
Duration: 60-90 minutes
Objective: Understand and defend against attacks through transitive dependencies
Skills: Dependency tree analysis, transitive dependency auditing, detection techniques
Description: Learn how attackers compromise packages that are dependencies of dependencies. This scenario demonstrates why transitive dependencies are hard to detect and how to audit entire dependency trees. Based on real-world attacks like event-stream β flatmap-stream (2018).
Duration: 60-90 minutes
Objective: Understand and defend against lock file manipulation attacks
Skills: Lock file validation, integrity checking, CI/CD security
Description: Learn how attackers manipulate package-lock.json to inject malicious packages. This scenario demonstrates why lock files are trusted by package managers and how to detect and prevent lock file tampering. Critical for CI/CD pipeline security.
Duration: 90+ minutes
Objective: Understand and defend against signing bypass attacks through key compromise
Skills: Signature verification, key management, key rotation, behavioral analysis
Description: Learn how attackers compromise package signing keys to sign malicious packages. This scenario demonstrates why signature verification alone is insufficient and how to detect key compromise. Based on real-world attacks like SolarWinds (2020).
Duration: 60-90 minutes
Objective: Understand and defend against attacks through malicious git submodules
Skills: Submodule validation, .gitmodules analysis, repository security
Description: Learn how attackers add malicious git submodules to legitimate repositories. This scenario demonstrates how submodules can execute code automatically and how to detect and prevent submodule attacks.
Duration: 90+ minutes
Objective: Understand and defend against attacks through compromised registry mirrors
Skills: Mirror validation, upstream verification, registry security
Description: Learn how attackers compromise internal npm registry mirrors to serve malicious packages. This enterprise-specific scenario demonstrates why mirrors are single points of failure and how to validate mirror integrity. Critical for organizations using internal package registries.
Duration: 60-90 minutes
Objective: Understand and defend against attacks through compromised workspace packages
Skills: Workspace security, monorepo auditing, postinstall monitoring
Description: Learn how attackers compromise packages within npm workspaces or monorepos. This scenario demonstrates why workspace packages are a critical attack vector and how one compromised package can affect all packages in the workspace. Common in modern development with monorepo tools like Lerna, Nx, and Turborepo.
Each scenario includes:
- β Detection techniques and tools
- β Mitigation strategies
- β Best practices for prevention
- β Real-world case studies
IMPORTANT: This test bench is for educational purposes only.
- β Use ONLY in isolated environments
- β Never deploy malicious code to public repositories
- β Do not test on systems you don't own
- β Follow responsible disclosure practices
All malicious packages in this testbench are:
- Clearly labeled as educational
- Designed to work only in the test environment
- Incapable of causing real harm when used as instructed
This repository contains intentionally vulnerable code and malicious package examples for educational purposes. All examples include safeguards to prevent accidental deployment:
- Environment variable checks (requires
TESTBENCH_MODE=enabled) - Localhost-only operations
- Clear warning messages
- No actual credential harvesting
- Zero to Hero Guide β START HERE if you're new!
- Quick Reference Card - Essential commands cheat sheet
- Complete Setup Guide
- Quick Start Guide
- Best Practices
- Scenario Walkthroughs (if exists)
- Defense Strategies (if exists)
- Troubleshooting (if exists)
- Additional Resources - External links, articles, tools, and references
Recommended Order:
- Read background material on supply chain attacks
- Complete scenarios in order (1-6)
- Review detection tools and techniques
- Implement defenses in the vulnerable applications
- Create your own attack scenario (capstone)
Note: Scenario 6 (Shai-Hulud) is the most advanced and should be attempted after completing scenarios 1-5, as it combines multiple attack vectors and requires understanding of incident response procedures. Scenarios 7-8, 10, 12 are intermediate level. Scenarios 9, 11 are advanced - Scenario 9 requires understanding of cryptographic signing, and Scenario 11 is enterprise-specific and requires understanding of internal registry infrastructure. Scenario 12 is common in modern development and requires understanding of npm workspaces and monorepo structure.
This is an educational project. Contributions are welcome:
- New attack scenarios
- Improved detection tools
- Better documentation
- Bug fixes and enhancements
MIT License - See LICENSE file for details
Based on real-world supply chain attacks including:
- SolarWinds (2020)
- CodeCov (2021)
- Event-stream (2018)
- UA-Parser-js (2021)
- Colors.js & Faker.js (2022)
For questions or issues:
- Open an issue on GitHub
- Check the troubleshooting guide
- Review the FAQ in docs/
Remember: With great power comes great responsibility. Use these skills to defend, not to harm.
π Happy Learning!