CVE-2026-115754: serialize-javascript 7.0.1 before 7.1.3 XSS via unescaped </script in function body
Serialize JavaScript serializes JavaScript values to a superset of JSON that includes regular expressions and functions. Prior to 7.1.3, the function-source escaping logic does not neutralize a bare closing-script prefix when attacker-influenced function source text ends exactly at that prefix. Because each function body is escaped independently, a delimiter supplied by surrounding serialized output can terminate an HTML script element, and a later serialized value supplies injected markup that becomes a live element in the page. Exploitation requires control of a serialized function's source text, such as through a spoofed toString(). This issue is fixed in version 7.1.3.
Other sources
serialize-javascript 7.0.1 before 7.1.3 XSS via unescaped </script in function body
— Microsoft
serialize-javascript from 7.0.1 before 7.1.3 contains a cross-site scripting vulnerability that allows attackers to break out of HTML script elements by ending serialized function source text with an unescaped </script. Attackers controlling a function's source via a spoofed toString() can combine surrounding output delimiters and later values to inject live markup such as img onerror handlers.
— Ubuntu
serialize-javascript from 7.0.1 before 7.1.3 contains a cross-site scripting vulnerability that allows attackers to break out of HTML script elements by ending serialized function source text with an unescaped /script. Attackers controlling a function's source via a spoofed toString() can combine surrounding output delimiters and later values to inject live markup such as img onerror handlers.
— IBM
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
debian/node-serialize-javascriptto a version that resolves this vulnerability.Fixed in 7.1.4+~5.0.4-1 - Upgrade
Upgrade
npm/serialize-javascriptto a version that resolves this vulnerability.Fixed in 7.1.3
Event History
Frequently Asked Questions
Which deployments are exposed?
Deployments using serialize-javascript versions 7.0.1 through before 7.1.3 are affected when serialized output is placed inside an HTML script element. The issue is relevant where attacker-controlled input can influence a function's source representation.
What does an attacker need to exploit this?
An attacker needs to control a function's source through a spoofed toString() result and have the application serialize that function into HTML script output. Exploitation also relies on combining output delimiters and later values to form injected markup.
What should be done to remediate the issue?
Update serialize-javascript to version 7.1.3 or later. If updating cannot happen immediately, avoid placing serialized function output influenced by untrusted input into HTML script elements.