CVE-2026-41305: PostCSS has XSS via Unescaped </style> in its CSS Stringify Output

Published Apr 24, 2026
·
Updated

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

javascript 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: javascript output = output.replace(/<\/(style)/gi, '<\\/$1');

Credits Discovered and reported by Sunil Kumar (@TharVid)

Other sources

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.

IBM

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.

NVD

Affected Software

5 affected componentsFixes available
npm/postcss<8.5.10
npm/postcss<8.5.10
8.5.10
IBM Engineering AI Hub<=1.0.0
IBM Engineering AI Hub<=1.1.0
IBM Engineering AI Hub<=1.2.0

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade npm/postcss to a version that resolves this vulnerability.

    Fixed in 8.5.10
  2. Upgrade

    Upgrade postcss to a version that resolves this vulnerability.

    Fixed in 8.5.10
  3. Configuration

    Ensure the PostCSS CSS stringification step escapes `</style` sequences (and effectively `/style` sequences) in all stringified output values before embedding in an HTML `<style>` tag.

    PostCSS CSS stringification output Escape closing style sequences (`</style` / `</style>` and `/style` in stringified values) = Escape `</style` sequences in all stringified output values

Event History

Apr 24, 2026
CVE Published
via MITRE·02:27 AM
Data Sourced
via MITRE·02:27 AM
DescriptionSeverityWeakness
Data Sourced
via NVD·03:16 AM
DescriptionSeverityWeakness
Advisory Published
via GitHub·03:31 PM
Data Sourced
via GitHub·03:31 PM
DescriptionSeverityWeaknessAffected Software
Jul 14, 2026
Data Sourced
via IBM·12:00 AM
DescriptionAffected Software

Parent advisories

This vulnerability appears in the following advisories.

Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is the severity of CVE-2026-41305?

CVE-2026-41305 is classified as a Cross-Site Scripting (XSS) vulnerability that could lead to serious security issues in web applications.

2

How do I fix CVE-2026-41305?

To fix CVE-2026-41305, upgrade PostCSS to version 8.5.10 or later.

3

What software is affected by CVE-2026-41305?

CVE-2026-41305 affects PostCSS versions prior to 8.5.10.

4

What type of vulnerability is CVE-2026-41305?

CVE-2026-41305 is an XSS vulnerability caused by unescaped </style> sequences in CSS Stringify Output.

5

How does CVE-2026-41305 impact web applications?

CVE-2026-41305 allows attackers to execute arbitrary scripts in the context of the user in affected web applications.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203