CVE-2026-41305

CVE-2026-41305 is a medium-severity cross-site scripting (XSS) vulnerability in postcss (npm), affecting versions < 8.5.10. It is fixed in 8.5.10.

Summary

PostCSS: XSS via Unescaped </style> in CSS Stringify Output

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

Credits

Discovered and reported by Sunil Kumar (@TharVid)

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.

Untrusted input is rendered as active markup in a victim's browser, which can run script in their session. Typical impact: session or credential theft, and actions taken as the user.

CVE-2026-41305 has a CVSS score of 6.1 (Medium). The vector is network-reachable, no privileges required, and user interaction required. A CVSS score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether this affects your application depends on whether the vulnerable code is present and reachable in your environment. A fixed version is available (8.5.10); upgrading removes the vulnerable code path.

Affected versions

postcss (< 8.5.10)

Security releases

postcss → 8.5.10 (npm)

Kodem intelligence

Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.

Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.

See it in your environment

Remediation advice

Escape </style in all stringified output values:

output = output.replace(/<\/(style)/gi, '<\\/$1');

Frequently Asked Questions

  1. What is CVE-2026-41305? CVE-2026-41305 is a medium-severity cross-site scripting (XSS) vulnerability in postcss (npm), affecting versions < 8.5.10. It is fixed in 8.5.10. Untrusted input is rendered as active markup in a victim's browser, which can run script in their session.
  2. How severe is CVE-2026-41305? CVE-2026-41305 has a CVSS score of 6.1 (Medium). This score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether it represents real risk in your environment depends on whether the vulnerable code is present and reachable.
  3. Which versions of postcss are affected by CVE-2026-41305? postcss (npm) versions < 8.5.10 is affected.
  4. Is there a fix for CVE-2026-41305? Yes. CVE-2026-41305 is fixed in 8.5.10. Upgrade to this version or later.
  5. Is CVE-2026-41305 exploitable, and should I be worried? Whether CVE-2026-41305 is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
  6. What actually determines whether CVE-2026-41305 is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
  7. How do I fix CVE-2026-41305? Upgrade postcss to 8.5.10 or later.

Other vulnerabilities in postcss

CVE-2023-44270CVE-2021-23382CVE-2021-23368

Stop the waste.
Protect your environment with Kodem.