【问题标题】:What is the "RegExp DoS issue"?什么是“RegExp DoS 问题”?
【发布时间】:2016-10-17 10:36:10
【问题描述】:

我刚刚在服务器中安装了 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。但是,由于服务器没有使用最新版本的节点,这对我来说是新的并开始调查:

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 不够熟悉,无法将其全部跟踪到最后一个小细节)。

【问题讨论】:

  • 问题记录在here

标签: javascript node.js npm minimatch


【解决方案1】:

从您链接到 (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) {

可能是那个窒息的人。

【讨论】:

  • 太棒了!这与 cmets 中提到的official sourcerobertklep 中的解释相符。
猜你喜欢
  • 2017-06-19
  • 2023-03-04
  • 2010-09-10
  • 2012-03-05
  • 2011-03-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-06-15
相关资源
最近更新 更多