GitHub Advisoryadvisory · npm
GHSA-jp4x-w63m-7wgm Prototype Pollution in hoek
HIGH
Official page ↗
- Aliases
- CVE-2018-3728
- Ecosystem
- npm
- Packages
- hoek
- Severity
- High
- CVSS vector
- CVSS:3.0/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
- Weaknesses
- CWE-1321
- Reviewed
- 2020-06-16
Affected packages
• npm hoek: >= 5.0.0, < 5.0.3 → fixed in 5.0.3
• npm hoek: < 4.2.1 → fixed in 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:
```javascript
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.
Related
Alias · CVE (1)
- CVE-2018-3728 hoek node module before 4.2.0 and 5.0.x before 5.0.3 suffers from a Modification of Assumed-Immutable Data (MAID) vulnerability via 'merge'… vulnerability
Weakness · CWE (1)
- CWE-1321 Improperly Controlled Modification of Object Prototype Attributes weakness
References
- https://nvd.nist.gov/vuln/detail/CVE-2018-3728 advisory
- https://github.com/hapijs/hoek/commit/32ed5c9413321fbc37da5ca81a7cbab693786dee web
- https://github.com/hapijs/hoek/commit/5aed1a8c4a3d55722d1c799f2368857bf418d6df web
- https://hackerone.com/reports/310439 web
- https://access.redhat.com/errata/RHSA-2018:1263 web
- https://access.redhat.com/errata/RHSA-2018:1264 web
- https://github.com/hapijs/hoek package
- https://snyk.io/vuln/npm:hoek:20180212 web
- https://web.archive.org/web/20200227131737/https://www.securityfocus.com/bid/103108 web