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

时间:2020-05-01 01:58:40

标签: reactjs npm

我正在开始一个新的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.

我尝试了google,并在任何地方寻找解决此问题的方法,但我没有成功安装yargs-parser软件包,然后尝试重新安装了该项目几次。

任何帮助将不胜感激。

3 个答案:

答案 0 :(得分:14)

目前还没有立即解决的方法。自yargs-parser固定以来,react-scripts的版本已发生重大变化。我们正在等待react-scripts进行更新,以解决此警告。

值得注意的是,这不是一个“严重的”漏洞,仅会影响开发环境。它已在最新的yargs-parser中修复,但是我不会因为低风险漏洞而失眠。它们不时发生,社区通常非常擅长修补它们。

您可以在以下位置查看此问题的进展,或者(取决于您的技能水平)为解决问题做出贡献:https://github.com/facebook/create-react-app/issues/8529

答案 1 :(得分:5)

我们也需要添加它:

“脚本”:{ “ preinstall”:“ npx npm-force-resolutions” }

然后在package.json上添加:

“决议”:{ “ yargs-parser”:“ ^ 13.1.2” }

最后在您的终端上按以下常规运行:

rm -r node_modules

npm安装

答案 2 :(得分:-2)

  1. 尝试npm audit fix
  2. 如果步骤1不起作用,请按照该漏洞所在的路径进行操作 是。对于你的情况,路径是
     (your main project folder)/node_modules/react-scripts/webpack-dev-server/yargs/yargs- 
      parser
    
    您应该在那里找到package.json文件。打开它并找到 yargs-parser版本。如果版本不是审核中提到的版本 报告[检查审计报告中的补丁。这些是推荐的版本,然后尝试 通过从该目录运行命令npm i yargs-parser从该目录升级yargs-parser。然后返回到主目录 项目文件夹,然后再次尝试命令npm install(有时可以工作 无需再次安装npm。因此在运行npm install之前运行 npm audit检查其是否解决。如果解决,则无需运行 再次npm install

检查易受攻击的yargs-parser版本: https://snyk.io/vuln/npm:yargs-parser