# CVE-2017-5954: serialize-to-js arbitrary code execution through IIFE

Source: https://junglewise.ai/threats/cve-2017-5954-serialize-to-js-arbitrary-code-execution-through-iife  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2018-07-18. Updated: 2026-09-25  
License: CC BY 4.0 with a link back

CVE-2017-5954 · Severity: low · CVSS 3 · Published 2018-07-18

serialize-to-js is a JavaScript library used to deserialize data structures from strings. The library's deserialize function fails to properly validate input, allowing attackers to execute arbitrary code by injecting an Immediately Invoked Function Expression (IIFE). This can lead to complete compromise of any application using this library to process untrusted data.

Technologies: [serialize-to-js (npm)](https://junglewise.ai/threats/technologies/serialize-to-js). Vendors: [npm](https://junglewise.ai/threats/vendors/npm).

## Quick answers

**Is CVE-2017-5954 exploited in the wild?** No. Junglewise Threat Intelligence has no report of CVE-2017-5954 being exploited in the wild.

**How severe is CVE-2017-5954?** Low severity, with a CVSS score of 3, published 18 July 2018.

**Which products and versions are affected?** serialize-to-js (npm) SEMVER:introduced=0,fixed=1.0.0.

**Is there a fix for CVE-2017-5954?** Yes. serialize-to-js (npm): upgrade to 1.0.0 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is CVE-2017-5954 attacked?** It is attacked over the network, in a software library.

**Am I affected by CVE-2017-5954?** Check whether you run serialize-to-js (npm) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## How to fix

- serialize-to-js (npm): upgrade to 1.0.0 or later

  ```sh
  npm install serialize-to-js@1.0.0
  ```


## Technical details

The vulnerability is a deserialization code execution flaw (CWE-502) in the serialize-to-js library's deserialize() function. The root cause is unsafe use of new Function() to parse serialized data, which allows injection of function expressions that execute immediately. An attacker can craft a malicious serialized payload containing an IIFE (e.g., "(function(){ eval('...')})()") that executes arbitrary JavaScript code when deserialized. No authentication or user interaction is required—only network access to send untrusted data to an application using the vulnerable library. The vulnerability was fixed in version 1.0.0 and later.

## Affected products

- commenthol serialize-to-js before 1.0.0

## Identifiers

- CVE-2017-5954
- GHSA-mm62-wxc8-cf7m

## Timeline

- 2017-02-09: disclosed
- 2017: patched: Fixed in version 1.0.0
- 2018-07-18: advisory

## References

- [https://github.com/commenthol/serialize-to-js/issues/1](https://github.com/commenthol/serialize-to-js/issues/1)

## Related threats

- [serialize-to-js denial of service](https://junglewise.ai/threats/serialize-to-js-denial-of-service-133dbaec)
- [commenthol serialize-to-js XSS in serialized regular expressions](https://junglewise.ai/threats/cve-2019-16772-commenthol-serialize-to-js-xss-in-serialized-regular-expressions)
