Add supply_chain_install_remote_source rule (protect npm/pnpm install shorthands)#57
Draft
sarahxsanders wants to merge 1 commit into
Draft
Add supply_chain_install_remote_source rule (protect npm/pnpm install shorthands)#57sarahxsanders wants to merge 1 commit into
sarahxsanders wants to merge 1 commit into
Conversation
Flags JS package-manager installs that pull from a non-registry source (remote .tgz/.tar.gz tarball URLs or git repos), which bypass registry review and run lifecycle scripts from arbitrary state. Newly relevant now that bare `npm i` / `pnpm i` shorthands are allowlisted for agents, so a plain `npm i <pkg>` no longer prompts. Generated-By: PostHog Code Task-Id: e5588221-b812-402e-904f-9641a83e6c1b
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem and acceptable goal
Problem this change addresses
To let smaller/faster models (e.g. gpt-5-mini) run without unnecessary permission prompts, the agent allowlist is being widened to permit shorthand install commands like
npm iandpnpm i. Once a barenpm i <arg>no longer prompts, the newly-reachable risk is an agent being steered intonpm i <remote-source>— installing straight from a remote tarball URL or a git repo, which bypasses the registry's published-version review and runs the fetched package's lifecycle scripts from arbitrary state. This is a classic supply-chain vector and nothing in the Warlock caught it. This PR adds a narrow rule for that shape while deliberately leaving benignnpm i <pkg-name>unflagged.Why the Warlock is the right home for this change:
Detecting a dangerous content shape in a shell command is exactly the Warlock's job. The allowlist widening lives in the consumer (harness), but the pattern-detection that protects the shapes around it belongs with the other
supply_chaininstall rules (supply_chain_npm_install_global,supply_chain_wrong_posthog_package), not duplicated in each consumer.Changes
supply_chain_install_remote_source(severityhigh, categorysupply_chain, actionblock,scan_context = command) matching JS package-manager installs (npm/pnpm/yarn/bun/cnpm) from a remote.tgz/.tar.gztarball URL or a git source (git+https,git+ssh,git://,git@host:,github:/gitlab:/bitbucket:).--registryflag pointing at a registry root, a local-path install, or deno (URL installs are idiomatic there).npm i <pkg>/pnpm i <pkg>shorthands the allowlist change enables.Anti-goal check
Test plan
pnpm test) — 532 passedpnpm build)scan_contextmetadata (command)Created with PostHog from a Slack thread