概述
Vue 是一个 HTML、CSS 和 JS 框架,用于开发具有细粒度反应性的网络应用程序。
在 Vue 2 编译器中发现了 ReDoS 漏洞(CVE-2024-9506)。
根据OWASP:正则表达式拒绝服务(ReDoS)是一种拒绝服务攻击,它利用了大多数正则表达式实现可能达到极端情况,导致其工作速度非常缓慢(与输入大小呈指数关系)这一事实。攻击者可以使使用正则表达式(Regex)的程序进入这些极端情况,然后挂起很长一段时间。
详细信息
模块信息
- 产品Vue
- 受影响的软件包:compiler-sfc、server-renderer、template-compiler
- Affected versions: >=2.0.0 <3.0.0
- Github 存储库: https://github.com/vuejs/vue
- 发布包: https://www.npmjs.com/package/vue
- 软件包管理器:npm
漏洞信息
在多个 Vue 软件包中的html-parser.ts 文件中发现了这个低严重性漏洞:
- 编译器-sfc
- 服务器渲染器
- 模板编译器
- vue-template-compiler
- vue-server-renderer
当出现以下情况时,html-parser.ts中的 Vue 的parseHTML()函数容易受到 ReDoS 攻击:
- The template string contains a <script>, <style>, or <textarea> without a matching closing tag
Within the parseHTML() function there is a regular expression (regex) to check for proper closing tags for the three tags listed above. However, due to an improperly written regex, when you pass in something like <script>some very very long text</not-script> it will trigger a ReDoS.
复制步骤
Within Vue 2 client-side application code, create a new Vue instance with a template string that includes a <script> node tag that has a different closing tag (in this case </textarea>).
new Vue({
el: '#app',
template: '
<div>
Hello, world!
<script>${'<'.repeat(1000000)}</textarea>
</div>'
});
- 设置一个加载上述 JavaScript 的index.html文件,然后使用mount()挂载新创建的 Vue 实例。
<!DOCTYPE html>
<html>
<head>
<title>My first Vue app</title>
</head>
<body>
<div id="app">
Loading..
</div>
</body>
</html>
- 在浏览器中访问您的 Vue 应用程序
http://localhost:3000
- 在浏览器中,观察 ReDoS 漏洞如何增加页面解析模板和挂载 Vue 应用程序所需的时间。这演示了 ReDoS 漏洞。
概念验证
与上述代码类似的完整复制品可在此处找到:
Vue2 HTML 标记不匹配 ReDoS
学分
- K(发现者)
缓解
Vue 2 已达到生命末期,将不会收到任何解决此问题的更新。
受影响组件的用户应采用以下缓解措施之一:
- 迁移到新版本的 Vue。
- 利用 HeroDevs 这样的商业支持合作伙伴提供 EOL 后的安全支持。
每当我们支持的开源软件修复了新的漏洞,我们就会发出警报。