Skip to content

A comprehensive cybersecurity learning platform for understanding, practicing, and defending against supply chain attacks.

License

Notifications You must be signed in to change notification settings

RAJANAGORI/supply-chain-attack-simulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

23 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Supply Chain Attack Test Bench πŸ”

A comprehensive cybersecurity learning platform for understanding, practicing, and defending against supply chain attacks.

🎯 Overview

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.

πŸš€ What You'll Learn

  • 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

πŸ“‹ Prerequisites

  • 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.)

πŸ—οΈ Project Structure

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

πŸŽ“ New to This Project?

If you're completely new and want step-by-step guidance:

  1. Run the interactive starter script:

    chmod +x START_HERE.sh
    ./START_HERE.sh
  2. 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.

πŸ”§ Quick Start

1. Clone the Repository

git clone <repository-url>
cd testbench

2. Run Setup Script

chmod +x scripts/setup.sh
./scripts/setup.sh

3. Begin Your First Scenario

cd scenarios/01-typosquatting
cat README.md  # Read the scenario instructions

πŸ“š Scenario Overview

Scenario 1: Typosquatting Attack (Beginner)

Duration: 30-45 minutes
Objective: Create and exploit a typosquatted package to exfiltrate data
Skills: Package creation, social engineering, data exfiltration

Scenario 2: Dependency Confusion (Intermediate)

Duration: 45-60 minutes
Objective: Exploit private/public package resolution to inject malicious code
Skills: Package registry manipulation, scope confusion

Scenario 3: Compromised Package (Intermediate)

Duration: 60 minutes
Objective: Simulate account takeover and malicious package update
Skills: Credential compromise, package hijacking

Scenario 4: Malicious Update (Advanced)

Duration: 60-90 minutes
Objective: Deploy a trojan update that appears legitimate
Skills: Code obfuscation, persistence techniques

Scenario 5: Build System Compromise (Advanced)

Duration: 90+ minutes
Objective: Compromise CI/CD pipeline to inject backdoors
Skills: Pipeline manipulation, artifact poisoning

Scenario 6: Shai-Hulud Self-Replicating Attack (Expert)

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.

Scenario 7: Transitive Dependency Attack (Intermediate)

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

Scenario 8: Package Lock File Manipulation (Intermediate)

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.

Scenario 9: Package Signing Bypass (Advanced)

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

Scenario 10: Git Submodule Attack (Intermediate)

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.

Scenario 11: Registry Mirror Poisoning (Advanced)

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.

Scenario 12: Workspace/Monorepo Attack (Intermediate)

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.

πŸ›‘οΈ Defense & Detection

Each scenario includes:

  • βœ… Detection techniques and tools
  • βœ… Mitigation strategies
  • βœ… Best practices for prevention
  • βœ… Real-world case studies

⚠️ Safety & Ethics

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

πŸ”’ Security Notice

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

πŸ“– Documentation

πŸŽ“ Learning Path

Recommended Order:

  1. Read background material on supply chain attacks
  2. Complete scenarios in order (1-6)
  3. Review detection tools and techniques
  4. Implement defenses in the vulnerable applications
  5. 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.

🀝 Contributing

This is an educational project. Contributions are welcome:

  • New attack scenarios
  • Improved detection tools
  • Better documentation
  • Bug fixes and enhancements

πŸ“œ License

MIT License - See LICENSE file for details

πŸ™ Acknowledgments

Based on real-world supply chain attacks including:

  • SolarWinds (2020)
  • CodeCov (2021)
  • Event-stream (2018)
  • UA-Parser-js (2021)
  • Colors.js & Faker.js (2022)

πŸ“ž Support

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!

About

A comprehensive cybersecurity learning platform for understanding, practicing, and defending against supply chain attacks.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published