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

postcss Updated 24 Apr 2026

Summary

24/04/2026
Yes i
Moderate
6.1

CVE-2026-41305: PostCSS has XSS via Unescaped in its CSS Stringify Output. Affects postcss versions < 8.5.10. Fixed in 8.5.10. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Penetration testing for web, API and mobile Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

PostCSS is a widely used tool in the web development ecosystem that allows developers to transform CSS with JavaScript plugins. It enables features like autoprefixing, linting, and minification, making CSS more manageable and efficient. However, a vulnerability has been identified in version 8.5.5 that poses a risk of cross-site scripting (XSS) attacks due to improper handling of certain string sequences during the CSS stringification process.

Vulnerability Detail

The vulnerability arises from PostCSS's failure to escape the sequence </style> when stringifying CSS Abstract Syntax Trees (ASTs). This oversight allows user-submitted CSS containing this sequence to break out of the intended style context when embedded in HTML <style> tags. As a result, malicious scripts can be injected and executed in the browser, leading to potential XSS attacks. The issue is particularly concerning for applications that parse and re-stringify user-generated CSS without adequate sanitization.

How To Fix

Latest published version: 8.5.31 as of 22 Oct 2026

npm install postcss@8.5.31

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

8.5.10

This is the first release that contains the fix.

npm install postcss@8.5.10

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

If immediate updating is not feasible, a temporary workaround involves escaping the </style> sequence in the output. You can implement the following code snippet to sanitize the output: output =

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

This will prevent the closing of the <style> tag and mitigate the risk of XSS.

Conclusion

The vulnerability identified as CVE-2026-41305 in PostCSS poses a significant risk of XSS attacks due to unescaped </style> sequences in CSS stringification. It is crucial for developers using PostCSS to update to version 8.5.10 or later to safeguard their applications. Implementing the provided workaround can offer temporary relief until the update is applied.

See every vulnerability recorded for postcss →

Share this vulnerability

FAQ

The CVSS score for this vulnerability is 6.1, indicating a moderate severity level.

You can use Vulert, which monitors open-source vulnerabilities in real-time. By analyzing your package-lock.json file, Vulert can alert you to any vulnerabilities, including this one.

The primary impact is the risk of XSS attacks, which can lead to unauthorized script execution, data theft, or other malicious activities on affected web applications.

Yes, you can implement a workaround by escaping the </style> sequence in the CSS output to prevent XSS attacks until you can update to the patched version.

Detailed information can be found in the official advisory on GitHub or by checking the CVE entry for CVE-2026-41305.

Related vulnerabilities

Recent vulnerabilities recorded for postcss.

How To Fix

Latest published version: 8.5.31 as of 22 Oct 2026

npm install postcss@8.5.31

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

8.5.10

This is the first release that contains the fix.

npm install postcss@8.5.10

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback