serialize-javascript@7.1.2

Serialize JavaScript to a superset of JSON that includes regular expressions and functions.

  • latest version

    7.1.4

  • latest non vulnerable version

  • first published

    12 years ago

  • latest version published

    17 days ago

  • licenses detected

  • Direct Vulnerabilities

    Known vulnerabilities in the serialize-javascript package. This does not include vulnerabilities belonging to this package’s dependencies.

    Fix vulnerabilities automatically

    Snyk's AI Trust Platform automatically finds the best upgrade path and integrates with your development workflows. Secure your code at zero cost.

    Fix for free
    VulnerabilityVulnerable Version
    • L
    Cross-site Scripting (XSS)

    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 Cross-site Scripting (XSS) via escapeFunctionBody() in index.js, which escapes each function body in isolation and therefore fails to detect a </script sequence that appears at the very end of a serialized function body. Because the regex SCRIPT_CLOSE_REGEXP did not anchor to end-of-string, a function body terminating with the bare prefix </script was emitted unescaped, allowing a subsequent serialized value to supply the closing > and inject arbitrary markup into the surrounding HTML page.

    How to fix Cross-site Scripting (XSS)?

    Upgrade serialize-javascript to version 7.1.3 or higher.

    <7.1.3
    • L
    Cross-site Scripting (XSS)

    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 Cross-site Scripting (XSS) via escapeFunctionBody(), which escapes each function body in isolation. When a serialized function body ends with the bare token </script, the function does not see the delimiter that the surrounding output supplies next (such as the newline added by the space option), so the sequence is emitted unescaped. An attacker who can influence a serialized function body can close the enclosing <script> tag and inject arbitrary markup into the page, leading to cross-site scripting.

    How to fix Cross-site Scripting (XSS)?

    Upgrade serialize-javascript to version 7.1.3 or higher.

    <7.1.3