Supply chain security

From superagent-ai/skills · View interactive version

Supply chain security is an AI agent skill from the GitHub repository superagent-ai/skills. Review new or changed dependencies for supply-chain compromise before they enter a project — malicious install scripts (preinstall/postinstall), binding.gyp/node-gyp install-time execution (June 2026 worm), self-propagating worms (Shai-Hulud, binding.gyp), credential harvesting and exfiltration, obf

How to use this skill

Skill file

Supply-Chain Security Scanner

This skill turns the model into a dependency reviewer. Read the manifests, lockfiles, install scripts, and the dependency diff; walk the detection passes; report each supply-chain risk with a severity and a concrete fix. No tools to install, no package to run, no registry to phone — the analysis is the model reading what's on disk and in the diff.

A dependency is the one thing in your project you didn't write and didn't review, running with your full privileges. The defender's problem is that it looks legitimate: the largest npm compromise in history rode chalk and debug (2 billion weekly downloads) through a phished maintainer, and the Shai-Hulud worm backdoored ~800 packages by republishing them under stolen tokens. Popularity is not safety. The moment to catch this is when a dependency is added or changed — that is what this skill reviews.

Mental model

A new or changed dependency runs code from a stranger twice: once at install time (lifecycle scripts — on your laptop and your CI runner, before a single line is reviewed) and again at runtime (in your app, your users' browsers, your servers). Two questions decide whether it is safe:

The install-time hook is the crown jewel. It executes before any code review, on developer machines and CI runners, with full environment and token access — which is exactly why every major worm (Shai-Hulud, the nx s1ngularity attack, the June 2026 binding.gyp campaign) targets install time. Most land in preinstall / postinstall; the binding.gyp worm bypasses those hooks entirely by tricking node-gyp into running arbitrary shell during a fake native build. A package can be perfectly functional and still own your machine the instant you install it.

When you cannot confirm a package's identity, or cannot explain what its install script does, treat it as untrusted and flag it. The cost of a false positive is a held PR and a few minutes. The cost of a false negative is every credential on the machine and in CI — and your own packages republished as the next link in the worm. This asymmetry governs every judgment call below.

Scan procedure

Walk these passes in order. Pass 0 establishes what you're reviewing and what's new — don't skip it.

Pass 0: scope what you're reviewing

You can't assess a dependency without knowing the ecosystem and how much of it you can actually see.

Pass 1: identity — is this the package you meant?

Before behavior, confirm the name resolves to who you think.

Pass 2: install-time execution — the crown jewel

Read every lifecycle script. In npm: preinstall, install, postinstall, and prepare in package.json scripts. Equivalents elsewhere: setup.py / PEP 517 build hooks (PyPI), native extconf.rb (RubyGems), build.rs (Cargo). preinstall is the loudest signal — Shai-Hulud 2.0 moved there specifically to run before any inspection tooling.

Also read binding.gyp if present. When npm sees one, it invokes node-gyp to compile what it assumes is a native addon — even with ignore-scripts=true, because this is not a lifecycle hook. The June 2026 binding.gyp worm keeps package.json scripts clean and hides execution in a ~100-byte binding.gyp that abuses shell expansion in the sources array:

// [P0] binding.gyp worm — node-gyp runs arbitrary shell during "compile"
{
  "targets": [{
    "target_name": "Setup",
    "type": "none",
    "sources": ["< $(node index.js >/dev/null) >/dev/null 2>&1 && echo stub.c)"]
  }]
}

That silently runs a root-level index.js (4.5–4.9 MB obfuscated in known campaigns) during npm install. Flag any binding.gyp in a package with no legitimate native code, any sources entry with $(), backticks, or shell redirection, and any type: "none" target whose only job is to trigger a command.

Legitimate install scripts exist: node-gyp, esbuild, sharp, bcrypt, playwright compile or download a platform binary into the package's own directory. Distinguish that from a script that:

// [P0] Shai-Hulud-class install hook — preinstall runs a dropped payload before review
{
  "name": "innocent-looking-util",
  "version": "1.2.4",
  "scripts": { "preinstall": "node setup_bun.js" }
}

The files setup_bun.js + bun_environment.js (Shai-Hulud 2.0/3.0), telemetry.js (s1ngularity), a malicious binding.gyp + root index.js (binding.gyp worm), or any install path that installs Bun to run an obfuscated blob are P0 on sight — treat the package as compromised, do not install, and rotate any credentials already exposed. See the campaign markers in references/checklist.md.

Pass 3: obfuscation and dynamic code

Obfuscation in a dependency that has no reason to obfuscate is itself the finding. Flag:

You don't have to fully deobfuscate it. A styling or date library that ships an encrypted payload and an eval is suspicious enough to block on.

Pass 4: credential and secret access

Malicious packages harvest everything reachable from the install or runtime context. Flag reads of:

Pass 5: exfiltration, C2, and self-propagation

Where harvested data goes, and how one compromised dependency becomes the next:

Pass 6: persistence and sabotage

Pass 7: integrity and version hygiene

This pass reads the manifest and lockfile, and applies even when you can't see the package source. Flag:

Finding format

Report each finding in this structure. Group by severity, P0 first.

[P0] malicious-install-script in package.json:14 (dependency: innocent-looking-util@1.2.4)
  Adds a `preinstall` hook running `node setup_bun.js`. This is the Shai-Hulud
  install-time worm pattern: the dropped payload installs the Bun runtime and runs
  an obfuscated credential stealer before any review, on every dev machine and CI
  runner that installs this package.

  Vulnerable:
    "scripts": { "preinstall": "node setup_bun.js" }

  Fix: do not install. Remove the dependency, delete node_modules and the lockfile
  entry, clear the npm cache, and rotate every credential reachable from machines
  that already installed it (npm, GitHub, cloud, SSH). Confirm against the published
  IOC lists before trusting any nearby version.

If the user pastes a manifest or snippet without a path, refer to "the manifest" / "the package" and use line numbers within the snippet. Always name the package and version, the pass that fired, and where the install or runtime context exposes secrets — that is the proof the dependency is dangerous and the spec for the fix.

Severity scale

When the dependencies look fine

After all passes, if nothing fires:

  1. Say so explicitly, and state what you verified: the ecosystem and files from Pass 0, the added/changed packages reviewed, that no install scripts (or only benign platform-build ones) are present, no obfuscation or credential/exfiltration patterns in the source you could see, and that versions are pinned with a committed, integrity-bearing lockfile.
  2. Note what a static read cannot confirm: the published tarball may differ from the source repo (the registry is the trust boundary, not GitHub); transitive dependencies you didn't open; runtime-only behavior; whether the version on the registry right now matches what you reviewed; and reputation, age, and provenance, which need a registry/OSV query you didn't run.
  3. Recommend the confirming commands (the user runs these against public data — the skill itself stays offline): npm audit signatures (provenance), osv-scanner --lockfile=... (known-malicious/CVE), for a JS/TS project cve-lite-cli (the OWASP local-first lockfile scanner — OSV matching across npm/pnpm/yarn/bun with direct-vs-transitive visibility, copy-and-run --fix remediation, and an --offline advisory DB; matches known-advisory vulns, so it complements rather than replaces the behavioral passes above), npm view <pkg> time (recency, for a cooldown decision), and a Socket/Snyk/Aikido behavioral check. Plus a cooldown (min-release-age / minimumReleaseAge, 1–7 days) so a freshly published compromise gets caught by the community before it lands. Walk references/checklist.md for a full audit.

A clean static read does not prove the installed artifact is safe.

Reference files

What this skill won't do

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.