原型污染 - npm漏洞无法修复?

17

我正在开始一个新的React项目,只安装了最基础的包(npx create-react-app),没有安装其他任何东西。当我运行审核时,出现以下低风险漏洞:

                       === npm audit security report ===                        
                                                                                
┌──────────────────────────────────────────────────────────────────────────────┐
│                                Manual Review                                 │
│            Some vulnerabilities require your attention to resolve            │
│                                                                              │
│         Visit https://go.npm.me/audit-guide for additional guidance          │
└──────────────────────────────────────────────────────────────────────────────┘
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ Low           │ Prototype Pollution                                          │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package       │ yargs-parser                                                 │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in    │ >=13.1.2 <14.0.0 || >=15.0.1 <16.0.0 || >=18.1.2             │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ react-scripts                                                │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path          │ react-scripts > webpack-dev-server > yargs > yargs-parser    │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info     │ https://npmjs.com/advisories/1500                            │
└───────────────┴──────────────────────────────────────────────────────────────┘
found 1 low severity vulnerability in 1896 scanned packages
  1 vulnerability requires manual review. See the full report for details.

我尝试使用谷歌并在各地寻找解决方法,重新安装yargs-parser包但没有成功,并尝试多次重新安装该项目。

如果有帮助,将不胜感激。


4
请不要发布文字截图。这样无法搜索或复制,并且用户体验较差。相反,请将代码直接粘贴到您的问题中。如果您选中它并点击 {} 按钮或按下 Ctrl+K,代码块将缩进四个空格,从而使其呈现为代码。 - Chris
2个回答

16

目前还没有立即解决方案。自从固定在react-scripts中的版本以来,yargs-parser的版本已经存在破坏性的更改。我们正在等待更新react-scripts以解决此警告。

值得注意的是,这不是一个“严重”的漏洞,应该只影响开发环境。最新的yargs-parser已修复了这个问题,但我不会对低风险漏洞感到担忧。这种情况偶尔会发生,社区通常很擅长修补它们。

您可以在此处查看此问题的进展,或根据您的技能水平为修复贡献力量:https://github.com/facebook/create-react-app/issues/8529


6
我们需要添加以下内容:

"scripts": { "preinstall": "npx npm-force-resolutions" }

然后在你的 package.json 文件中添加:

"resolutions": { "yargs-parser": "^13.1.2" }

最后在终端下运行以下命令:

rm -r node_modules

npm install


4
你能否再解释一下这些命令在做什么?谢谢! - Matthew
1
@Matthew,preinstall脚本在运行npm install时被调用,并且在npm实际安装之前运行。 npm-force-resolutions 修改package.json以强制安装传递依赖项(依赖项的依赖项)的特定版本。因此,基本上可以确保在运行npm install时安装的yargs-parser版本将是13.1.2或任何更新的次要版本。 - Thijs

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接