Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: yahoo/serialize-javascript
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v7.1.1
Choose a base ref
...
head repository: yahoo/serialize-javascript
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
  • 9 commits
  • 7 files changed
  • 3 contributors

Commits on Sep 23, 2026

  1. Merge commit from fork

    * fix: prevent script close tag from being swallowed by a single match
    
    `SCRIPT_CLOSE_REGEXP` matched `<\/script[^>]*>`, whose wildcard could run
    from one `</script` to the next `>` anywhere in the function source. When a
    second, complete `</script>` fell inside that span, the whole thing collapsed
    into one match, and since the plain-code branch neutralizes only the leading
    `<`, the swallowed tag was re-emitted verbatim.
    
    A function body reaches that shape whenever `</script` appears in code
    position -- `x</script=+/` parses as `x < /script=+/`, a comparison against a
    regex literal -- followed by a `</script>` in a later string. The serialized
    output then carries a live `</script>`, which terminates the script element
    when embedded the way the README documents, so the rest of the payload is
    parsed as HTML. Confirmed in headless Chromium: the injected `onerror` runs.
    
    This regressed in v7.1.0. v7.0.7 used the same wildcard but escaped the
    entire match, so nothing survived.
    
    Excluding `<` from the character class fixes it: a match can no longer reach
    past a second `<`, so every `</script` in the source either starts its own
    match or is followed by a non-delimiter -- and the HTML tokenizer only ends
    the tag name on TAB, LF, FF, CR, SPACE, `/` or `>`, emitting anything else as
    text.
    
    Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
    
    * fix: reject spoofed function toString() and make native-code check stateless
    
    Two defects in `serializeFunc`, found while investigating the script close
    tag escaping.
    
    `fn.toString()` was trusted to return a string. It is attacker-controlled in
    the same way `URL.prototype.toString` and `RegExp.prototype.source` were
    before they were hardened. Returning an object with its own `replace()` is
    enough to defeat the escaping outright, because `escapeFunctionBody()` is
    built entirely from `str.replace(...)` calls -- the object's `replace` simply
    returns itself, and the payload reaches the output untouched:
    
        var f = function () {};
        f.toString = () => ({
            replace: function () { return this; },
            toString: () => 'function(){}</script><img src=x onerror=alert(1)>'
        });
        serialize({ f: f });
        // {"f":function(){}</script><img src=x onerror=alert(1)>}
    
    A primitive string from a spoofed `toString()` was already safe; only the
    non-string case bypasses escaping. Rejecting it matches how the URL and
    RegExp spoofing cases are already handled.
    
    Separately, `IS_NATIVE_CODE_REGEXP` carried a `/g` flag. `.test()` on a
    global regexp advances `lastIndex`, so after one rejection the next call
    began its scan past the `[native code]` match and returned false, letting
    every other native function through:
    
        try { serialize(Math.max); } catch (e) {}  // correctly throws
        serialize(Math.min);                       // 'function min() { [native code] }'
    
    That output is a syntax error rather than an injection, so the impact is
    limited to an unreliable guard, but the flag serves no purpose here.
    
    Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
    
    ---------
    
    Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
    redonkulus and claude authored Sep 23, 2026
    Configuration menu
    Copy the full SHA
    2bdbaaf View commit details
    Browse the repository at this point in the history
  2. release: v7.1.2

    redonkulus committed Sep 23, 2026
    Configuration menu
    Copy the full SHA
    6a73fa1 View commit details
    Browse the repository at this point in the history

Commits on Oct 22, 2026

  1. fix: escape </script at the end of a serialized function body (#235)

    `escapeFunctionBody()` escapes each function body on its own, so a body
    ending in a bare `</script` never saw the delimiter that the surrounding
    output supplies next (e.g. the newline from the `space` option). The
    sequence was emitted raw, letting a later value close the tag and inject
    markup. Also match the bare form at end of string.
    
    Fixes PSECBUGS-118415.
    
    Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
    redonkulus and claude authored Oct 22, 2026
    Configuration menu
    Copy the full SHA
    2864b3c View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    e978a1b View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    45e5397 View commit details
    Browse the repository at this point in the history
  4. release: v7.1.3 (#236)

    Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
    redonkulus and claude authored Oct 22, 2026
    Configuration menu
    Copy the full SHA
    4d36b82 View commit details
    Browse the repository at this point in the history

Commits on Oct 23, 2026

  1. docs: add SECURITY.md pointing to private vulnerability reporting (#237)

    Researchers had no documented channel for reporting vulnerabilities, so
    reports arrived by personal email. Point them to GitHub's private
    vulnerability reporting (now enabled), list supported versions, and
    spell out the function-source threat model.
    
    Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
    redonkulus and claude authored Oct 23, 2026
    Configuration menu
    Copy the full SHA
    f7dfeae View commit details
    Browse the repository at this point in the history
  2. Fix methods containing nested functions and arrows (#231)

    * fix: detect outer functions before serializing method bodies
    
    * test: preserve commented async function signatures
    
    * fix: preserve class expressions during serialization
    Shubham-Padkonde authored Oct 23, 2026
    Configuration menu
    Copy the full SHA
    fdb853d View commit details
    Browse the repository at this point in the history
  3. release: v7.1.4 (#238)

    Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
    redonkulus and claude authored Oct 23, 2026
    Configuration menu
    Copy the full SHA
    05c5ceb View commit details
    Browse the repository at this point in the history
Loading