Cloudanix VulnDB

CVE-2018-14732

High · 7.5

CVSS

7.5

EPSS

2.6%

Published

Sep 21, 2018

CISA due date

—

Cloudanix analysis

Next patch cycle SSVC: Track

A malicious website could silently read code updates from an old local development server running on a developer’s machine.

Exploit Available
Exploitation
Remote Unauthenticated
Attacker needs
None
Complexity
Low
Impact
Data Exposure
Component
Web Framework
Class
Improper Input Validation
Remediation
Upgrade
Effort
Medium
Patch risk
Low

What it actually does

webpack-dev-server versions before 3.1.6 fail to validate the Origin header on the WebSocket endpoint used for Hot Module Replacement (HMR). Because the HMR WebSocket can be reached from an arbitrary web origin, a malicious website can cause a developer's browser to connect to a locally running webpack-dev-server instance, such as ws://127.0.0.1:8080/, and receive HMR messages. Those messages may contain application module updates, source code fragments, build metadata, paths, and other development-only information. The primary impact is unauthorized disclosure of developer source code and related implementation details; integrity and availability are not directly affected by the flaw itself.

Why it matters to the business

If developers run vulnerable webpack-dev-server instances, proprietary application code and internal implementation details can be exposed to an attacker simply by a developer visiting a malicious page while the dev server is running. This can lead to intellectual property loss, easier discovery of application vulnerabilities, leakage of API routes or client-side secrets accidentally embedded in development builds, and increased risk to downstream products that rely on webpack-dev-server in development workflows. The issue is older and not listed in CISA KEV, but public exploit knowledge exists and the component is common in JavaScript development environments, so organizations should prioritize cleanup in developer workstations, CI/dev containers, and templates that still pin old versions.

How an attack unfolds

An attacker first identifies that an organization or developer population is likely to use vulnerable webpack-dev-server versions, or simply relies on opportunistic exposure through local development defaults. The attacker hosts a malicious webpage containing JavaScript that opens a WebSocket connection to a likely local webpack-dev-server address, commonly ws://127.0.0.1:8080/ or the HMR SockJS/WebSocket path used by webpack-dev-server. When a developer with a vulnerable dev server running visits that page, the browser allows the script to initiate the connection. Because the vulnerable server does not enforce an expected Origin value, it accepts the connection even though it came from an attacker-controlled website. The attacker-controlled page then listens for HMR traffic and relays any received module update payloads or build information to attacker infrastructure. As the developer edits or rebuilds code, HMR messages can reveal source code fragments and application internals without requiring credentials or direct network access to the development machine beyond the browser-mediated connection.

How to fix it

Upgrade webpack-dev-server to version 3.1.6 or later. For the affected Git source, the issue is fixed by commit f18e5adf123221a1015be63e1ca2491ca45b8d10. In package-managed projects, update package.json and lockfiles so webpack-dev-server resolves to a fixed release, then rebuild development containers and CI images that include JavaScript tooling. Remove stale global installations of webpack-dev-server and old project templates that pin vulnerable versions. As defense in depth, bind development servers to localhost only unless remote access is explicitly required, avoid exposing dev-server ports to untrusted networks, use firewall rules or container networking to restrict access, and do not rely on webpack-dev-server as a production web server. Where upgrade is temporarily blocked, restrict access to the dev-server port and avoid browsing untrusted sites while the vulnerable dev server is running, but treat this only as a temporary mitigation.

How to confirm the fix worked

Confirm that all project manifests and lockfiles resolve webpack-dev-server to 3.1.6 or later, or to source code containing commit f18e5adf123221a1015be63e1ca2491ca45b8d10. Use commands such as npm ls webpack-dev-server, yarn why webpack-dev-server, pnpm why webpack-dev-server, and checks of global npm packages to identify vulnerable installations. Validate container images and development VM baselines by inspecting installed node_modules and lockfiles. Functionally test by sending a WebSocket request to the HMR endpoint with an unexpected Origin header and confirming that the server rejects it or otherwise prevents cross-origin HMR subscription. Also verify that development servers are not listening on externally reachable interfaces unless explicitly intended.

Typical attack path

  1. Prepare a malicious webpage with JavaScript that attempts WebSocket connections to common local webpack-dev-server endpoints such as ws://127.0.0.1:8080/ and HMR/SockJS paths.
  2. Lure a developer into visiting the malicious page while a vulnerable webpack-dev-server instance is running locally or on an accessible development host.
  3. The browser sends a WebSocket upgrade request to the development server with an attacker-controlled Origin header.
  4. The vulnerable webpack-dev-server accepts the WebSocket connection because it does not validate the Origin header.
  5. The malicious page receives HMR messages containing hot-update payloads, module code, source paths, or build metadata.
  6. The malicious page exfiltrates the received HMR data to attacker-controlled infrastructure for analysis and reuse.

How to detect it

Retrospective detection is difficult because webpack-dev-server is a development tool and may not retain detailed WebSocket or HMR logs by default. Review browser history, proxy logs, EDR network telemetry, local firewall logs, and any dev-server access logs around periods when vulnerable webpack-dev-server instances were running. Look for WebSocket upgrade requests to local or development-host ports, especially 8080, with Origin headers pointing to unrelated external websites. In HTTP telemetry, investigate requests to HMR endpoints such as /sockjs-node or WebSocket upgrade requests that include unexpected Origin values. On endpoints, look for browsers connecting to 127.0.0.1, localhost, or development-server addresses on webpack-dev-server ports shortly after visiting unfamiliar external domains. If packet capture, browser devtools logs, or proxy captures are available, search for HMR payload markers such as webpackHotUpdate, hot-update.js, hot-update.json, module source text, or source map references being sent to unknown external domains. Also investigate evidence of exfiltration from browser processes to suspicious remote hosts immediately after receiving local HMR traffic.

  • ws://127.0.0.1:8080/
  • ws://localhost:8080/
  • GET /sockjs-node
  • Upgrade: websocket
  • Origin: http://
  • Origin: https://
  • webpackHotUpdate
  • hot-update.js
  • hot-update.json
  • .hot-update.js
  • .hot-update.json
  • __webpack_require__
  • webpack-dev-server
  • webpack/hot/dev-server
  • webpack-dev-server/client
  • f18e5adf123221a1015be63e1ca2491ca45b8d10

What your security team should do

  • Inventory all repositories, developer base images, CI images, and project templates for webpack-dev-server versions earlier than 3.1.6.
  • Prioritize upgrades in active development projects and shared starter templates so vulnerable versions are not reintroduced through dependency pinning or lockfiles.
  • Search for globally installed or cached webpack-dev-server versions on developer workstations and ephemeral development environments, not only application repositories.
  • Restrict development-server ports such as 8080 and HMR/SockJS endpoints to localhost or trusted networks using host firewalls, container networking, and IDE/dev-environment defaults.
  • Add software composition analysis rules that fail builds or pull requests when webpack-dev-server earlier than 3.1.6 is introduced.
  • Educate developers that local development servers can expose code to malicious webpages and should not be left running unnecessarily while browsing untrusted sites.
  • Review historical telemetry for suspicious WebSocket connections to local dev-server ports with non-local or unexpected Origin headers.

The record

An issue was discovered in lib/Server.js in webpack-dev-server before 3.1.6. Attackers are able to steal developer's code because the origin of requests is not checked by the WebSocket server, which is used for HMR (Hot Module Replacement). Anyone can receive the HMR message sent by the WebSocket server via a ws://127.0.0.1:8080/ connection from any origin.

Affected packages

Ecosystem Package Introduced Fixed
npm webpack-dev-server 0 3.1.11

Related vulnerabilities