gpt4 book ai didi

javascript - 什么是 "RegExp DoS issue"?

转载 作者:IT老高 更新时间:2023-10-28 23:19:42 26 4
gpt4 key购买 nike

我刚刚在服务器上安装了 nodejs,一个基本的 npm install 显示了很多这样的消息:

$ npm install
npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated minimatch@0.2.14: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated graceful-fs@1.2.3: graceful-fs v3.0.0 and before will fail on node releases >= v7.0. Please update to graceful-fs@^4.0.0 as soon as possible. Use 'npm ls graceful-fs' to find it in the tree.
npm WARN deprecated graceful-fs@2.0.3: graceful-fs v3.0.0 and before will fail on node releases >= v7.0. Please update to graceful-fs@^4.0.0 as soon as possible. Use 'npm ls graceful-fs' to find it in the tree.
npm WARN prefer global node-gyp@3.4.0 should be installed with -g

注意出现在右侧的消息:

npm WARN ... or higher to avoid a RegExp DoS issue
^^^^^^^^^^^^^^^^^^^^^^^^^^^

在我的本地服务器中,我已经在使用 minimatch 3.0.3。但是,由于服务器没有使用最新版本的 Node ,这对我来说是新的并开始调查:

npm's github 中报告了此问题并在其他问题中提到它。一般情况下,将minimatch的版本升级到至少3.0.2即可解决。

但是,我想知道这个 RegExp DoS 问题是什么?是否有任何特定的正则表达式允许通过 minimatch 进行 DoS 攻击?我无法想象这是怎么发生的,也不想重现它,但我找不到更多文档和 minimatch's Github list of issues一点痕迹都没有。

来自 releases pages我看到了the only commit for the 3.0.2 release ,其中基本上封装了正则表达式语法(我对 JavaScript 不够熟悉,无法将其全部跟踪到最后一个小细节)。

最佳答案

从您链接到的提交 (https://github.com/isaacs/minimatch/commit/6944abf9e0694bd22fd9dad293faa40c2bc8a955):

在提交中添加的测试正在制作这样的正则表达式:

var exploit = '!(' + genstr(1024 * 15, '\\') + 'A)'

这是创建一个以 '!(' 开头的字符串,然后是 \ 的 1024*15 个副本,然后是 'A)'。那一定是 DoS 条件。

这一行

tail = tail.replace(/((?:\\{2}){0,64})(\\?)\|/g, function (_, $1, $2) {

可能是那个窒息的人。

关于javascript - 什么是 "RegExp DoS issue"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40084163/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com