Courses3 levels
Level 1 · Foundations11 courses
Level 2 · Core5 courses
Level 3 · Advanced5 courses
Labs8 topics
Library Practice exams AI Range Pricing Start free

Practice library / Penetration testing, first steps

Lab · Hard · 3 hoursFree account

Supply Chain Attacks

A malicious package and a tampered build script compromise a lab build pipeline, then the logs catch each one.

  • supply-chain
  • dependency-confusion
  • package-hijacking
  • build-pipeline
On this page 14 sections
  1. ·What you need first
  2. ·Lab setup
  3. ·Build the target
  4. 1Find the build host and its unpinned dependency
  5. 2Stand up a package registry you control
  6. Locked: Build the malicious package
  7. Locked: Point the build at your registry and trigger it
  8. Locked: Decide what the foothold is worth
  9. Locked: Tamper the build script itself
  10. Locked: Detect both attacks
  11. Locked: Close both openings
  12. Locked: Check
  13. Locked: Clean-up
  14. Locked: Next lab

Build pipelines trust the packages they install and the scripts they run. An attacker who publishes a package with the right name, or who edits one trusted script, inherits the pipeline's service account rights. The SolarWinds and event-stream incidents followed a similar pattern. In this lab, you run both attacks against a lab build host, catches each one in registry evidence and Windows logs, then closes the gap.

Lab Objectives

  • Map a build host and its service account as attack surface
  • Exploit a dependency-confusion opening to run code inside a lab build pipeline
  • Build a malicious package with a working proof-of-execution payload
  • Tamper with a build script as a second, independent supply-chain path
  • Detect both attacks from registry evidence and Windows event IDs
  • Apply the controls that close each opening

What you need first

Complete these items before you start:

Active Directory Fundamentals explains service accounts and group membership, if Active Directory Basics left questions.

This lab builds a foothold as a service account. These labs show what that foothold is worth: AD Enumeration with CrackMapExec, Windows Privilege Escalation, Windows Lateral Movement and AD Enumeration with BloodHound. NTLM Relay Attacks and MSSQL, Exchange & SCCM Attacks abuse other over-privileged service accounts the same way.

Lab setup

Build this in your own isolated lab network. Use the domain CORP.LOCAL.

ItemRequirement
DomainCORP.LOCAL, with one domain controller.
DC01The domain controller. IP 10.0.0.10.
BUILD01A domain-joined Windows Server, IP 10.0.0.20. It runs the lab's build pipeline.
ATTACK01Kali Linux on the same network, IP 10.0.0.50. This is your machine as the authorised tester.
Account you start withA normal domain user, CORP\bob, password BuildLab-26!q. This is the access the engagement gave you.
Build identityCORP\svc_build, a member of the local Administrators group on BUILD01. You are never given its password; getting code to run as this account is the point of the lab.
RepositoryA git repository named product-api, checked out at ~/product-api on ATTACK01 (read-only copy) and at C:\Build\product-api on BUILD01 (the copy the pipeline uses). It holds package.json and a pipeline script, build.ps1.
PipelineA Windows scheduled task, ProductAPIBuild, that runs build.ps1 as CORP\svc_build.
SoftwareNode.js LTS and npm on ATTACK01 and BUILD01. Git on both. Verdaccio on ATTACK01 (Step 2 installs it).

Build the target

KaliRange hosts no targets, no virtual machines and no lab files. You run this lab on your own machine, against a network that you build. The names and 10.0.0.x addresses in this lab are the example addresses of the lab. Replace them with your own.

The table above lists the hosts and the accounts. Your own network must also have these parts, because the steps use them:

  • bob is a plain domain user with the description Developer. svc_build has the description Build pipeline service account, is a member of the local group Administrators on BUILD01 and of the domain group Build Operators, and has a password that you set and do not use in any command (Steps 1, 4 and 5).
  • Both machines can reach the same git remote origin with the branch main, and bob can push to it. build.ps1 and package.json have the content that Steps 1 and 6 print. The folder tests holds a file run.js that exits without an error, and the repository has no package-lock.json.
  • The scheduled task ProductAPIBuild on BUILD01 runs build.ps1 as CORP\svc_build, with a stored password ("run whether the user is logged on or not"), so that its logon is a batch logon (type 4, Step 7). bob can start it with schtasks /run.
  • BUILD01 reaches ATTACK01 on port 4873 (Step 4). Verdaccio listens on localhost only by default, so set its listen option to 0.0.0.0:4873 in its configuration file.
  • The npm config set registry command in Step 4 must apply to svc_build, because the task runs as that account. Run it in the profile of svc_build, or add the --global option.

Build such a network from free, legal parts. Install an evaluation copy of Windows Server from the Microsoft Evaluation Center (180 days) in virtual machines on your own computer for DC01 and BUILD01, and run Kali Linux in a third virtual machine. Keep the three machines on a network that has no route to the internet or to any network that you do not own. Take a snapshot of each virtual machine before Step 1.

Authorised lab only. Build this environment yourself. Never point any step at a real company's package registry or a pipeline you do not own. The techniques below work the same way against real build systems; the only thing that changes in this lab is that every target is yours.

Before Step 1, turn on process-creation auditing on BUILD01. Steps 4 and 6 need it so Step 7 finds evidence.

powershellon BUILD01: turn on process auditing
auditpol /set /subcategory:"Process Creation" /success:enable
reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\System\Audit" /v ProcessCreationIncludeCmdLine_Enabled /t REG_DWORD /d 1 /f

Step 1: Find the build host and its unpinned dependency

1

Recon the pipeline

Confirm BUILD01 is a domain member. List the domain's user accounts and find the service account that runs builds. Then read the project's own dependency file.

bashon ATTACK01: confirm the host and find the service account
# Confirm BUILD01 is a domain member
crackmapexec smb 10.0.0.20 -u bob -p 'BuildLab-26!q'

# List domain accounts; a service account name stands out
crackmapexec smb 10.0.0.10 -u bob -p 'BuildLab-26!q' --users
textExample output: host and user list
SMB   10.0.0.20   445   BUILD01   [*] Windows Server 2022 (name:BUILD01) (domain:CORP.LOCAL)
SMB   10.0.0.20   445   BUILD01   [+] CORP.LOCAL\bob:BuildLab-26!q

SMB   10.0.0.10   445   DC01      [*] Windows Server 2022 (name:DC01) (domain:CORP.LOCAL)
SMB   10.0.0.10   445   DC01      -Username-                    -Last PW Set-       -BadPW- -Description-
SMB   10.0.0.10   445   DC01      Administrator                 2025-11-02 09:12    0
SMB   10.0.0.10   445   DC01      bob                           2025-11-02 09:20    0       Developer
SMB   10.0.0.10   445   DC01      svc_build                     2026-01-10 08:00    0       Build pipeline service account

svc_build names itself as a build account. A description field like this is common, and attackers read it the same way a defender's audit would.

bashread the project's dependency file
cat ~/product-api/package.json
ls ~/product-api/package-lock.json
textExample output: package.json and the missing lockfile
{
  "name": "product-api",
  "version": "1.0.0",
  "scripts": { "test": "node tests/run.js" },
  "dependencies": {
    "corp-build-utils": "^1.0.0"
  }
}
ls: cannot access '/home/kali/product-api/package-lock.json': No such file or directory

Why this matters. corp-build-utils is an unscoped name with a loose version range (^1.0.0 accepts any 1.x release) and no lockfile to pin an exact, hashed version. Nothing here ties the name to one trusted registry. That gap is the opening.

What a defender would see. Nothing yet. Reading a file you were already given legitimate access to leaves no attack evidence. The evidence starts at Step 4.

Step 2: Stand up a package registry you control

2

Install Verdaccio

Install and start a private npm registry on ATTACK01. Point npm at it, and register a user.

bashon ATTACK01: install and start Verdaccio
sudo npm install -g verdaccio
verdaccio
textExample output: Verdaccio startup
warn --- config file  - /home/kali/.config/verdaccio/config.yaml
warn --- plugin successfully loaded: verdaccio-htpasswd
warn --- plugin successfully loaded: verdaccio-audit
warn --- http address - http://localhost:4873/ - verdaccio/5.x.x

Leave this window open. In a second terminal:

bashpoint npm at your registry and register
npm config set registry http://127.0.0.1:4873/
npm adduser --registry http://127.0.0.1:4873/
textExample output: adduser
npm notice Log in on http://127.0.0.1:4873/
Username: attacker
Password:
Email: (this IS public) attacker@example.com
Logged in as attacker on http://127.0.0.1:4873/.

Why this matters. A real dependency-confusion attack publishes to whichever registry a misconfigured pipeline actually resolves an unscoped name against. That can be a public registry, an open internal proxy, or any other source where nothing locks the name or an integrity hash. This lab registry stands in for that target, without ever touching a real one.

Sign in to continue

9 more sections are for signed-in members. It is free: sign in with Google.

Related