
{"id":260140,"date":"2026-12-05T13:46:27","date_gmt":"2026-12-05T13:46:27","guid":{"rendered":"https:\/\/mycryptomania.com\/?p=260140"},"modified":"2026-12-05T13:46:27","modified_gmt":"2026-12-05T13:46:27","slug":"ignore-scripts-didnt-stop-this-one-git-dependencies-on-npm-10","status":"publish","type":"post","link":"https:\/\/mycryptomania.com\/?p=260140","title":{"rendered":"&#8211;ignore-scripts didn\u2019t stop this one: git dependencies on npm 10"},"content":{"rendered":"<p>You cloned a take-home repo from a recruiter. You know install scripts are the classic trap, so you\u00a0run:<\/p>\n<p>npm install &#8211;ignore-scripts<\/p>\n<p>On npm 10, that still runs code from a stranger, if one of the dependencies comes from\u00a0git.<\/p>\n<h3>What npm does with a git dependency<\/h3>\n<p>A dependency can point at a git repository instead of the registry:<\/p>\n<p>{<br \/>  &#8220;dependencies&#8221;: {<br \/>    &#8220;utils&#8221;: &#8220;github:someone\/utils&#8221;<br \/>  }<br \/>}<\/p>\n<p>npm can\u2019t install a git repo as it is, it has to pack it first. The npm docs say that if a package installed through git has a prepare script, its dependencies and devDependencies are installed and prepare is run before the package is packed and installed.<\/p>\n<p>So prepare in that other repository runs on your machine during your npm install. Nobody typed npm run\u00a0prepare.<\/p>\n<h3>The test<\/h3>\n<p>We built the smallest possible case, with a harmless marker instead of a\u00a0payload:<\/p>\n<p>a local git repo dep-demo whose prepare script writes a marker\u00a0filean app whose only dependency is &#8220;dep-demo&#8221;: &#8220;git+file:\/\/\/\u2026\/dep&#8221;npm install with and without &#8211;ignore-scripts, in a clean folder each\u00a0time<strong>npm 10.9.9 (bundled with Node 22)<\/strong>: plain npm install: prepare ran; npm install &#8211;ignore-scripts: prepare ran; ignore-scripts=true in project\u00a0.npmrc: prepare\u00a0ran<strong>npm 11.21.3<\/strong>: plain npm install: prepare ran; npm install &#8211;ignore-scripts: did not run; ignore-scripts=true in project\u00a0.npmrc: not\u00a0tested<\/p>\n<p>On npm 10.9.9 the flag made no difference for the git dependency. On npm 11.21.3 it stopped\u00a0it.<\/p>\n<p>We tested on Linux with a local git+file: URL. We did not test every 10.x release, and we only measured the local case; a github: URL should behave the same way according to the\u00a0docs.<\/p>\n<h3>Why this matters for take-home repos<\/h3>\n<p>&#8211;ignore-scripts is the advice most of us give, including us. It still helps: it stops the install hooks of registry packages and the project&#8217;s own preinstall and postinstall. But on npm 10 a git dependency is a hole in it, and git dependencies are rare enough in normal projects that one in a take-home repo is worth a closer look on its\u00a0own.<\/p>\n<h3>What to\u00a0do<\/h3>\n<p>Check your version: npm &#8211;version. If it starts with 10, assume the flag does not cover git dependencies.Before any install, read dependencies, devDependencies and optionalDependencies for anything that is not a version range: github:, git+, git:\/\/, tarball URLs,\u00a0file:.Look at overrides, resolutions and pnpm.overrides too. A git URL can hide there while dependencies looks\u00a0normal.Open untrusted repos in a throwaway VM or container, not on the laptop with your keys and\u00a0tokens.<\/p>\n<p>There is also an open npm bug report on a related problem: allowScripts not stopping a git dependency&#8217;s prepare, with a fix proposed in npm\/cli PR\u00a0#10342.<\/p>\n<p>If you want the step 2 and 3 checks done for you, npm-install-audit flags non-registry dependencies, including ones in overrides, without running anything from the repo: <a href=\"https:\/\/github.com\/cryptostrapon\/npm-install-audit\">https:\/\/github.com\/cryptostrapon\/npm-install-audit<\/a><\/p>\n<p>Have you ever seen a git dependency in a take-home project? What was in\u00a0it?<\/p>\n<p><a href=\"https:\/\/medium.com\/coinmonks\/ignore-scripts-didnt-stop-this-one-git-dependencies-on-npm-10-1a34f1ed8d71\">&#8211;ignore-scripts didn\u2019t stop this one: git dependencies on npm 10<\/a> was originally published in <a href=\"https:\/\/medium.com\/coinmonks\">Coinmonks<\/a> on Medium, where people are continuing the conversation by highlighting and responding to this story.<\/p>","protected":false},"excerpt":{"rendered":"<p>You cloned a take-home repo from a recruiter. You know install scripts are the classic trap, so you\u00a0run: npm install &#8211;ignore-scripts On npm 10, that still runs code from a stranger, if one of the dependencies comes from\u00a0git. What npm does with a git dependency A dependency can point at a git repository instead of [&hellip;]<\/p>\n","protected":false},"author":0,"featured_media":260141,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-260140","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-interesting"],"_links":{"self":[{"href":"https:\/\/mycryptomania.com\/index.php?rest_route=\/wp\/v2\/posts\/260140"}],"collection":[{"href":"https:\/\/mycryptomania.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mycryptomania.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/mycryptomania.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=260140"}],"version-history":[{"count":0,"href":"https:\/\/mycryptomania.com\/index.php?rest_route=\/wp\/v2\/posts\/260140\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/mycryptomania.com\/index.php?rest_route=\/wp\/v2\/media\/260141"}],"wp:attachment":[{"href":"https:\/\/mycryptomania.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=260140"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mycryptomania.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=260140"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mycryptomania.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=260140"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}