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.
On this page 14 sections
- ·What you need first
- ·Lab setup
- ·Build the target
- 1Find the build host and its unpinned dependency
- 2Stand up a package registry you control
- Locked: Build the malicious package
- Locked: Point the build at your registry and trigger it
- Locked: Decide what the foothold is worth
- Locked: Tamper the build script itself
- Locked: Detect both attacks
- Locked: Close both openings
- Locked: Check
- Locked: Clean-up
- 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 Basics. You must know what a domain, a domain controller and a service account are.
- Windows Command Line & PowerShell. You must read and write basic PowerShell.
- SMB Enumeration. Step 1 enumerates a host the same way.
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.
| Item | Requirement |
|---|---|
| Domain | CORP.LOCAL, with one domain controller. |
| DC01 | The domain controller. IP 10.0.0.10. |
| BUILD01 | A domain-joined Windows Server, IP 10.0.0.20. It runs the lab's build pipeline. |
| ATTACK01 | Kali Linux on the same network, IP 10.0.0.50. This is your machine as the authorised tester. |
| Account you start with | A normal domain user, CORP\bob, password BuildLab-26!q. This is the access the engagement gave you. |
| Build identity | CORP\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. |
| Repository | A 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. |
| Pipeline | A Windows scheduled task, ProductAPIBuild, that runs build.ps1 as CORP\svc_build. |
| Software | Node.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:
bobis a plain domain user with the descriptionDeveloper.svc_buildhas the descriptionBuild pipeline service account, is a member of the local groupAdministratorson BUILD01 and of the domain groupBuild 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
originwith the branchmain, andbobcan push to it.build.ps1andpackage.jsonhave the content that Steps 1 and 6 print. The foldertestsholds a filerun.jsthat exits without an error, and the repository has nopackage-lock.json. - The scheduled task
ProductAPIBuildon BUILD01 runsbuild.ps1asCORP\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).bobcan start it withschtasks /run. - BUILD01 reaches ATTACK01 on port 4873 (Step 4). Verdaccio listens on
localhostonly by default, so set itslistenoption to0.0.0.0:4873in its configuration file. - The
npm config set registrycommand in Step 4 must apply tosvc_build, because the task runs as that account. Run it in the profile ofsvc_build, or add the--globaloption.
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.
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 /fStep 1: Find the build host and its unpinned dependency
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.
# 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' --usersSMB 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 accountsvc_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.
cat ~/product-api/package.json
ls ~/product-api/package-lock.json{
"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 directoryWhy 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
Install Verdaccio
Install and start a private npm registry on ATTACK01. Point npm at it, and register a user.
sudo npm install -g verdaccio
verdacciowarn --- 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.xLeave this window open. In a second terminal:
npm config set registry http://127.0.0.1:4873/
npm adduser --registry http://127.0.0.1:4873/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.