由于 Insecure Credential Storage 和 Insecure Credential Storage,web3 安装失败

web3 install fails due to Insecure Credential Storage and Insecure Credential Storage

使用 npm 版本 7.12.0 在 Ubuntu 上安装最新的 web3 版本 1.3.5 失败,并出现几个高严重性错误。修复的典型时间范围是什么?

npm 审计报告

underscore 1.3.2 - 1.12.0
Severity: high
Arbitrary Code Execution - https://npmjs.com/advisories/1674\ No fix available
node_modules/underscore
..web3-bzz <=1.3.5
..Depends on vulnerable versions of underscore
..node_modules/web3-bzz
....web3 *
....Depends on vulnerable versions of web3-bzz
....Depends on vulnerable versions of web3-eth
....node_modules/web3
..web3-core-helpers *
..Depends on vulnerable versions of underscore
..node_modules/web3-core-helpers
....web3-eth-ens *
....Depends on vulnerable versions of underscore
....Depends on vulnerable versions of web3-core-helpers
....node_modules/web3-eth-ens
......web3-eth *
......Depends on vulnerable versions of underscore
......Depends on vulnerable versions of web3-eth-ens
......node_modules/web3-eth
....web3-providers-http *
....Depends on vulnerable versions of web3-core-helpers
....node_modules/web3-providers-http
..web3-core-method *
..Depends on vulnerable versions of underscore
..node_modules/web3-core-method
....web3-core *
....Depends on vulnerable versions of web3-core-method
....node_modules/web3-core
....web3-eth-personal *
....Depends on vulnerable versions of web3-core-method
....Depends on vulnerable versions of web3-net
....node_modules/web3-eth-personal
....web3-net <=1.0.0-beta.55 || >=1.2.0
....Depends on vulnerable versions of web3-core-method
....node_modules/web3-net
......web3-shh <=1.3.5
......Depends on vulnerable versions of web3-core-method
......Depends on vulnerable versions of web3-net
......node_modules/web3-shh
..web3-core-requestmanager *
..Depends on vulnerable versions of underscore
..node_modules/web3-core-requestmanager
..web3-core-subscriptions *
..Depends on vulnerable versions of underscore
..node_modules/web3-core-subscriptions
..web3-eth-abi *
..Depends on vulnerable versions of underscore
..node_modules/web3-eth-abi
..web3-eth-accounts *
..Depends on vulnerable versions of underscore
..node_modules/web3-eth-accounts
..web3-eth-contract *
..Depends on vulnerable versions of underscore
..node_modules/web3-eth-contract
..web3-providers-ipc *
..Depends on vulnerable versions of underscore
..node_modules/web3-providers-ipc
..web3-providers-ws *
..Depends on vulnerable versions of underscore
..node_modules/web3-providers-ws
..web3-utils >=1.0.0-beta.8
..Depends on vulnerable versions of underscore
..node_modules/web3-utils
....web3-eth-iban *
....Depends on vulnerable versions of web3-utils
....node_modules/web3-eth-iban

web3 *
Severity: high
Insecure Credential Storage - https://npmjs.com/advisories/877\ Depends on vulnerable versions of web3-bzz
Depends on vulnerable versions of web3-eth
No fix available
node_modules/web3

21 high severity vulnerabilities\

我们 运行 npm ci && npm audit --audit-level=high 在我们项目的 CI 管道中,我们今天遇到了这个下划线问题。

已经有GitHub issue了:

我们正在等待新版本(补丁)。在此之前,快速修复和可能的解决方案是在 package-lock.json 中搜索 underscore 并在那里手动更新 underscore 版本,因为 npm audit fix 不会自动修复它。

我们使用了 1.9.1 版本并更新到 1.12.1(在审计日志中列为稳定版本)。请为每个 下划线 的出现更改这些行:

  • 版本:1.9.1 => 1.12.1;
  • 已解决:https://registry.npmjs.org/underscore/-/underscore-1.9.1.tgz => https://registry.npmjs.org/underscore/-/underscore-1.12.1.tgz
  • 完整性:sha512-5/4etnCkd9c8gwgowi5/om/mYO5ajCaOgdzj/oW+0eQV9WxKBDZw5+ycmKmeaTXjInS/W0BzpGLo2xR2aBwZdg== => sha512-hEQt0+ZLDVUMhebKxL4x1BTtDY7bavVofhZ9KZ4aI26X9SRaE+Y3m83XUL1UP2jn8ynjndwCCpEHdUG+9pP1Tw==.

这样 npm ci 将从 package-lock.json 获取版本并且不会发生错误。但是npm install会忽略它...

如果需要,下面是这两个命令之间的区别:

更新

您也可以使用 npm-force-resolutions 包来设置 underscore 包的特定版本:

  1. "resolutions": { "underscore": "1.12.1" } 添加到您的 package.json;
  2. 可选择添加 preinstall 脚本,每次在 npm install 启动之前都会 运行:"scripts": { "preinstall": "npx npm-force-resolutions" };
  3. 运行 npm installnpx npm-force-resolutions 并在 package-lock.json 中查看您的更改。 npm audit 也不会发现这些漏洞。

最终更新

web3@1.3.6 所有修复都可用,您可以更新本地包。

谢谢,问题已关闭。我在 github 上看到 ChainSafe/web3.js 包含对下划线的修复,很快就会在 NPM 上。

此外,npm ls -all | grep underscore 表明该库是第 2、3 和 4 级的嵌套依赖项。感谢 link 到 NPM 上的 npm-force-resolution 以获得背景、进一步的说明和警告,以警告可能存在的安全漏洞。我有一个用于学习的沙盒系统。