Skip to content
DoS Disclosed report Intermediate CVE-2018-3728

Prototype pollution attack (Hoek)

The Hoek library's merge and applyToDefaults functions allow an attacker to modify the prototype of Object when they control part of the input structure. This lets an attacker add or modify properties that exist on all objects, potentially causing a denial of service or, with more complex payloads, remote code execution.

holyvier Follow

Originally disclosed on HackerOne

  • Triaged in 12 hours
  • Fixed in 9 days
  • Disclosed after 15 days

As discussed in #309391, here's the separate report for each of the library. This one is the information for the Hoek library.

Module:

hoek

Summary:

Utilities function in all the listed modules can be tricked into modify the prototype of "Object" when the attacker control part of the structure passed to these function. This can let an attacker add or modify existing property that will exist on all object.

Description:

Steps To Reproduce:

The simplest test case to reproduce the issue is the following code snippet. In the code snippet, "malicious_payload" would come from an endpoint which accepts JSON data. The test case also works with the "Hoek.applyToDefaults" function.

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 shows that an attacker can add attributes to all existing object on the server. Additional attribute can be used to change the execution code flow or cause error on every subsequent request by replacing "toString" or "valueOf".

Impact:

This vulnerability is garanteed to at least obtain denial of service as all the library allow the property "toString" and "valueOf" to be replaced by a "String". This breaks the express module and forces the server to either crash or return a 500 to every subsequent request.

More complex payload can be crafted to gain remote code execution (see PoC in #309391).

Supporting Material/References:

If extra information is needed don't hesitate to ask.

Impact

Variable. Server crash or the server becoming unable to respond to all request is garanteed, but more significant impact like remote code execution can be achieved in some cases.

The original report as published on HackerOne, by holyvier. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Impact

This vulnerability is guaranteed to at least cause denial of service by replacing toString or valueOf, which breaks the express module and forces the server to crash or return a 500 to every subsequent request; more complex payloads could achieve remote code execution.

What the attacker needed

Attacker controls JSON input; application uses Hoek merge or applyToDefaults

How it was found

  1. Require the Hoek library in a Node.js script.
  2. Create a malicious JSON payload containing a __proto__ key with a property.
  3. Parse the JSON and pass it to Hoek.merge along with an empty object.
  4. Observe that a new property appears on a separate empty object, showing the prototype was modified.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

In JavaScript, objects can inherit properties from a shared 'prototype' object. If an attacker can add properties to that shared prototype, every object in the program gets those properties, which can break things or let the attacker run code. This report shows that a library called Hoek lets that happen when it processes untrusted input.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

More by holyvier

View all

10 more disclosed reports, best first.

More from Node.js third-party modules

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.