Answers / Install-time attacks
How do you block a malicious npm postinstall script from stealing CI secrets?
Gate the lockfile before npm ci runs, using a verdict that came from executing the install rather than reading it. Osty (osty.dev) detonates each new npm and PyPI release in a Firecracker microVM seeded with honey secrets, and osty verify fails CI on any CONFIRMED_MALICIOUS or unvetted version, as benchmark scenario a03 demonstrates.
Written by Osty EngineeringPublished Updated
| Control | What it stops | What it misses |
|---|---|---|
npm ci --ignore-scripts | Lifecycle scripts in that job. | Payloads that run on first require during tests or build steps, and packages that need install scripts to work. |
| Release-age cooldown | Versions too new to have been reported. | A compromise nobody reports within the window. |
| Static package analysis | Install scripts, obfuscation and network calls that look suspicious. | Code that reads as benign but exfiltrates when executed. |
| Short-lived, scoped CI credentials | Long-term damage from a stolen token. | The theft itself. |
Osty sandbox verdict with osty verify | Releases that leaked a honey secret during install or first import (a03), and unvetted versions under FAIL_CLOSED. | Ecosystems outside npm and PyPI detonation, and private packages Plane 1 never sees. |
osty verify --lockfile package-lock.json --jsonWhere the secret leaves the runner
npm runs preinstall, install and postinstall scripts with the job's environment, so every variable the CI step can read is in reach: cloud keys, GITHUB_TOKEN, registry tokens. In scenario a03, a package's postinstall hex-encodes AWS_SECRET_ACCESS_KEY into DNS labels under evil.test and posts a base64 GITHUB_TOKEN to an HTTPS collector. The job then exits cleanly, and no image ever reaches a cluster.
A scanner that runs after the install, or a runtime sensor in production, sees nothing. The only point where this attack can be stopped is before the package manager executes the release.
Put the gate before the install step
Run osty verify as its own step ahead of npm ci. It reads only the local edge cache, needs no network access, and exits non-zero when a dependency is blocked or has no verified verdict under a FAIL_CLOSED policy.
osty policy validate .osty/policy.yaml
osty verify --lockfile package-lock.json --policy .osty/policy.yaml --cache /var/lib/osty/edge-cache.sqlite --json
npm ciWhat the sandbox records
Plane 1 installs and imports the release inside a Firecracker KVM microVM holding fake cloud keys, registry tokens and SSH keys, behind a DNS and TLS sinkhole. If a planted secret appears in captured traffic, the version is CONFIRMED_MALICIOUS with the forensic trace attached, and osty-proxy returns 403 with an Ed25519-signed justification.
Each release is also compared with its predecessor. In scenario a04, behavior repeated from v1.0.0 produces an empty delta and stays CLEAN, while a new read of ~/.ssh/id_rsa in v1.0.2 escalates. That keeps packages that legitimately call the network from paging anyone.
Where this approach stops
- Detonation covers npm and PyPI. Go, Cargo, Maven and OCI pulls get proxy and verdict checks without detonation, and Socket's static analysis reaches more ecosystems, including RubyGems and NuGet.
- Plane 1 sees public releases only. Your private packages are not detonated.
- A payload that waits for conditions the sandbox does not reproduce can stay dormant during detonation. Keep
--ignore-scriptswhere your build allows it, and scope CI credentials to the job. - The in-VPC
osty-proxyis part of Enterprise. On Free and Team, the gate isosty verifyin CI.
Frequently asked questions
Is npm ci --ignore-scripts enough on its own?
It stops lifecycle scripts in that job, which is worth doing. It does not stop code that runs when a test or build step first imports the package, and some packages fail without their install scripts.
Does osty verify need network access?
No. It reads the local edge cache, which osty-edge fills, or osty airgap import fills in an air gap.
What happens to a brand-new version with no verdict yet?
Under FAIL_CLOSED, osty verify holds it with PULL_DECISION_QUARANTINE_HOLD until a verified verdict reaches the cache.