Skip to content

Prototype Pollution in hoek

High severity GitHub Reviewed Published Apr 26, 2018 to the GitHub Advisory Database • Updated Sep 13, 2023

Package

npm hoek (npm)

Affected versions

>= 5.0.0, < 5.0.3
< 4.2.1

Patched versions

5.0.3
4.2.1

Description

Versions of hoek prior to 4.2.1 and 5.0.3 are vulnerable to prototype pollution.

The merge function, and the applyToDefaults and applyToDefaultsWithShallow functions which leverage merge behind the scenes, are vulnerable to a prototype pollution attack when provided an unvalidated payload created from a JSON string containing the __proto__ property.

This can be demonstrated like so:

var Hoek = require('hoek');
var malicious_payload = '{"__proto__":{"oops":"It works !"}}';

var a = {};
console.log("Before : " + a.oops);
Hoek.merge({}, JSON.parse(malicious_payload));
console.log("After : " + a.oops);

This type of attack can be used to overwrite existing properties causing a potential denial of service.

Recommendation

Update to version 4.2.1, 5.0.3 or later.

References

Published to the GitHub Advisory Database Apr 26, 2018
Reviewed Jun 16, 2020
Last updated Sep 13, 2023

Severity

High
8.8
/ 10

CVSS base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
Low
User interaction
None
Scope
Unchanged
Confidentiality
High
Integrity
High
Availability
High
CVSS:3.0/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H

Weaknesses

CVE ID

CVE-2018-3728

GHSA ID

GHSA-jp4x-w63m-7wgm

Source code

No known source code
Loading Checking history
See something to contribute? Suggest improvements for this vulnerability.