serialize-javascript@7.0.5

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

    20 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
    • 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 a regex flaw in SCRIPT_CLOSE_REGEXP that allows a live </script> tag to survive serialization. The previous pattern [^>]* permitted a single match to span from one </script to the next > anywhere in the function source, swallowing a complete </script> in between. Because only one replacement is emitted per match, the swallowed tag is re-emitted verbatim in the output. When the serialized value is embedded in an HTML page as the README documents, the injected tag terminates the script element and the remainder of the payload is parsed as HTML, enabling script injection. A function body reaches the vulnerable shape when </script appears in code position (e.g., as part of a comparison against a regex literal) followed by a </script> inside a later string literal.

    Note: This is only exploitable when the serialized output is embedded directly in an HTML page inside a <script> element, as described in the package README.

    How to fix Cross-site Scripting (XSS)?

    Upgrade serialize-javascript to version 7.1.2 or higher.

    <7.1.2