-
-
Notifications
You must be signed in to change notification settings - Fork 715
Commit a631dd7
authored
chore(deps): update dependency happy-dom to v20 [security] (#14492)
This PR contains the following updates:
| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [happy-dom](https://redirect.github.com/capricorn86/happy-dom) |
[`^19.0.0` ->
`^20.0.0`](https://renovatebot.com/diffs/npm/happy-dom/19.0.2/20.0.0) |
[](https://docs.renovatebot.com/merge-confidence/)
|
[](https://docs.renovatebot.com/merge-confidence/)
|
[](https://docs.renovatebot.com/merge-confidence/)
|
[](https://docs.renovatebot.com/merge-confidence/)
|
### GitHub Vulnerability Alerts
####
[CVE-2025-61927](https://redirect.github.com/capricorn86/happy-dom/security/advisories/GHSA-37j7-fg3j-429f)
# 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.
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 the
`require()` 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)
```javascript
const { Window } = require('happy-dom');
const window = new Window({ 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)
```javascript
const { Window } = require('happy-dom');
const window = new Window({ console });
window.document.write(`
<script>
const process = this.constructor.constructor('return process')();
console.log('PID:', process.pid);
</script>
`);
```
## Potential Impact
#### Server-Side Rendering (SSR)
```javascript
const { Window } = require('happy-dom');
const window = new Window();
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()` and `Function()` 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
4. 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 from
[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function).
By walking the constructor chain it's possible to get hold of
[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function)
at process level. As
[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function)
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.
---
### Release Notes
<details>
<summary>capricorn86/happy-dom (happy-dom)</summary>
###
[`v20.0.0`](https://redirect.github.com/capricorn86/happy-dom/compare/v19.0.2...819d15ba289495439eda8be360d92a614ce22405)
[Compare
Source](https://redirect.github.com/capricorn86/happy-dom/compare/v19.0.2...v20.0.0)
</details>
---
### Configuration
📅 **Schedule**: Branch creation - "" in timezone Asia/Shanghai,
Automerge - At any time (no schedule defined).
🚦 **Automerge**: Enabled.
♻ **Rebasing**: Whenever PR is behind base branch, or you tick the
rebase/retry checkbox.
🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.
---
- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box
---
This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/oxc-project/oxc).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MS4xNDMuMSIsInVwZGF0ZWRJblZlciI6IjQxLjE0My4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>1 parent d0a8e3e commit a631dd7Copy full SHA for a631dd7
File tree
Expand file treeCollapse file tree
2 files changed
+9
-9
lines changedOpen diff view settings
Filter options
- tasks/e2e
Expand file treeCollapse file tree
2 files changed
+9
-9
lines changedOpen diff view settings
Collapse file
+1-1Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
Collapse file
+8-8Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments