Arbitrary Code Injection

Affecting serialize-javascript package, versions <3.1.0

Report new vulnerabilities
Do your applications use this vulnerable package? Test your applications

Overview

serialize-javascript is a package to serialize JavaScript to a superset of JSON that includes regular expressions and functions.

Affected versions of this package are vulnerable to Arbitrary Code Injection. An object like {"foo": /1"/, "bar": "a\"@__R-<UID>-0__@"} would be serialized as {"foo": /1"/, "bar": "a\/1"/}, meaning an attacker could escape out of bar if they controlled both foo and bar and were able to guess the value of <UID>. UID is generated once on startup, is chosen using Math.random() and has a keyspace of roughly 4 billion, so within the realm of an online attack.

PoC

eval('('+ serialize({"foo": /1" + console.log(1)/i, "bar": '"@__R-<UID>-0__@'}) + ')');

Remediation

Upgrade serialize-javascript to version 3.1.0 or higher.

References

CVSS Score

7.7
high severity
  • Attack Vector
    Network
  • Attack Complexity
    High
  • Privileges Required
    None
  • User Interaction
    None
  • Scope
    Unchanged
  • Confidentiality
    High
  • Integrity
    High
  • Availability
    Low
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:L/E:P/RL:O/RC:C
Credit
Unknown
CVE
CVE-2020-7660
CWE
CWE-94
Snyk ID
SNYK-JS-SERIALIZEJAVASCRIPT-570062
Disclosed
19 May, 2020
Published
01 Jun, 2020