[test] Regression test for XSS-safe `GoogleTagManager#dataLayer` (#99464)
This is based on a vulnerability report we got without a reproduction.
The test shows `GoogleTagManager` is not vulnerable to XSS attacks.
`<GoogleTagManager dataLayer={...}>` serializes user-controlled values
into its inline init script via `JSON.stringify` without HTML escaping.
If such a value reaches an HTML document (or an HTML fragment parser in
a non-script context), a `</script>` sequence breaks out of the script
tag and the injected markup executes (XSS).
These assertions encode the safe behavior: the payload must never appear
unescaped in the served HTML, and it must never execute in the browser.
Closes https://linear.app/vercel/issue/NSEC-263
Closes https://github.com/vercel/next-js-mirror/pull/181
Showing
Please
register
or
sign in
to comment